Skip to content

[css-values] "fetch a style resource" should fall back to the CSSStyleSheet's location #12068

Closed

Description

@AtkinsSJ

In step 2 of "fetch a style resource" we have:

Let base be sheet’s stylesheet base URL if it is not null, otherwise environmentSettings’s API base URL. [CSSOM]

However, only stylesheets constructed from JS have a base URL set. For those that don't, I believe we should fall back to sheet's location, and only afterwards use the API base URL. As an example:

index.html

<!DOCTYPE html>
<style>
     @import url("data/sheet.css");
</style>
<div id="checkerboard"></div>

data/sheet.css

#checkerboard {
    background: url("image.png");
}

With the current algorithm, sheet has no base URL, so it would fall back to the API base URL, which is the document's location. It would thus try to load image.png instead of data/image.png. Inserting the sheet's location as a fallback means that it would load relative to data/sheet.css, and so get data/image.png.

Activity

  1. weinig commented on Apr 15, 2025

    @weinig
    Contributor
  2. noamr commented on Apr 17, 2025

    @noamr
    Collaborator

    Makes sense, Happy to fix this once #12074 is merged (will do an overhaul of a few of these bugs in one go)

  3. self-assigned this
    on Jun 2, 2025
  4. added a commit that references this issue on Jun 2, 2025
    2366187
  5. added a commit that references this issue on Jun 3, 2025
    034a433
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions