-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
What is the URL of a CSSStyleSheet created via the constructor? #10
Comments
The CSSOM spec says location is specified when created, but naively I thought it can be deferred until it is added to somewhere (e.g. Is there any situation that copying document base URL becomes problematic? |
A naive solution would be to use the document URL that the current running inline script belongs to (I don't think anyone except Blink cares about HTML imports, but in that case At this moment a CSSStyleSheet is constructed from string, I think the above is a reasonable default. |
Why would there necessarily be a running inline script?
|
@bzbarsky I would assume in that case it would be |
Of which HTMLElement? The one the event handler is on? Is that also what happens if the event handler was assigned via The simplest thing, of course, is to use the base url of the document of the constructor's Realm global (which is a Window, presumably). Still have to decide whether it gets copied or aliased, of course. |
@bzbarsky I might have misused the term, I meant Let's decide on using document base url of the constructor's Realm global. Let me scratch Any objections / opinions? |
The term is correct for that, but in my example above there is no
Is that aliased, or snapshotted at the point when the constructor is called? |
As far as I imagine I'd go with snapshot when the constructor is called, but my imagination can be very small-scoped. What's the case when aliasing is useful...? In other words, does dynamic change of a document's base url happen so often, or even if it is rare, can following the change by aliasing be useful? |
I'm not sure there's an obvious case, but what do inline stylesheets end up doing? We should probably at least consider matching them here.
Often enough, with pushState and single-page apps.... |
Hmm, interesting, so if pushState() changes the document's URL, and delayed loading of |
I think this is the latest reference
|
Found a note below the part that I quoted above:
So... in many cases browser don't recalculate Related to #2, maybe we should hang the factory method under |
I think the constructor is only useful if there’s an instance method to parse style sheets asynchronously. That’s only useful if the spec for custom element styles proposal allows modification of the style sheet after the element has been defined which so far they seem opposed to despite my push back. Ultimately there might not be any real use case for the constructor. |
Maybe my last comment was not clear, but rather than StyleSheet.createFromString(text) , hanging the API on document
can make it clear about the association of the constructed stylesheet with the document (much like |
#35 resolves this - We use the |
Couldn't a |
How, exactly? |
The There are obviously more efficient ways of passing the dependency (through a JS API), I'm just trying to find a way to reuse pre-existing concepts.
|
Browsers already do this, for all URIs, if the URI has been parsed into a sheet.
Thinking of |
This is true of blobs in general, but in this case we're not fetching the blob, but the CSSStyleSheet directly. If it has been paged out, setting up the dependency will be slow, no matter how the dep is defined (through |
This matters for base URL bits in the CSS and some DOM APIs. In general, need to define https://drafts.csswg.org/cssom/#concept-css-style-sheet-location
The text was updated successfully, but these errors were encountered: