[cssom-1] Refactor CSSStyleSheet constructor and replaceSync to allow steps to be referenced from HTML spec#6411
Conversation
…be referenced directly from HTML spec, for use with CSS module scripts
|
This refactoring doesn't change any behavior, so not sure if a CSSWG resolution is necessary. Happy to discuss in a meeting if necessary. @mfreed7, FYI. I'd drafted an earlier version of this at WICG/construct-stylesheets#138 but missed the train on #6304. 😊 |
|
This change looks good to me! Thanks for cleaning it up in the process, and sorry for the churn on WICG/construct-stylesheets#138. |
|
Gentle ping @emilio and @tabatkins - this PR is blocking the CSS Modules PR. |
|
Sorry for the lag, I was on vacation until today. Will take a look ASAP, thanks. |
|
So I'm curious, why do you need the initialization to be separate from construction? That means that we need to define what a constructed but not initialized stylesheet does. Why can't it just use the CSSStyleSheet constructor? The "synchronously replace the rules of a CSSStyleSheet" bit looks great though. |
I don't think it's necessary for them to be separate. I've pushed a change to move the creation and initialization into the same set of steps. Thanks! |
emilio
left a comment
There was a problem hiding this comment.
Other than that nit, it looks basically good to me, thanks!
[cssom-1] Refactor CSSStyleSheet constructor and replaceSync to allow steps to be referenced from HTML spec
The CSS module scripts feature is being specified in HTML using several algorithms defined in cssom-1 on the
CSSStyleSheetinterface. In the review of the CSS module scripts HTML spec PR whatwg/html#4898, there was a concern that referencing the CSSStyleSheet methods directly implies that if these methods were overridden by user script, the UA should call the user script instead.This change pulls the steps for the
CSSStyleSheetconstructor andreplaceSyncemethod into separate algorithms so that they can be safely referenced from the HTML spec.