| Summary: | Implement CSSStyleSheet ReplaceSync() Functionality | ||
|---|---|---|---|
| Product: | WebKit | Reporter: | karl <karl+webkit> |
| Component: | CSS | Assignee: | Nobody <webkit-unassigned> |
| Status: | RESOLVED DUPLICATE | ||
| Severity: | Normal | CC: | a.praetorius, cdumez, dino, karlcow, kevin_neal, koivisto, webkit-bug-importer |
| Priority: | P2 | Keywords: | BrowserCompat, InRadar |
| Version: | Safari Technology Preview | ||
| Hardware: | Mac (Intel) | ||
| OS: | All | ||
|
Description
karl
2021-09-30 17:53:48 PDT
Thank you for filing. The appropriate engineers have been notified. I tried to use the app today for a project and realize it was not working. And discovered I had already filed a bug for this. ^_^ This depends on implementing https://drafts.csswg.org/cssom/#dom-cssstylesheet-replacesync replaceSync can be found on GitHub here and there. 4754 occurrences, (probably not only the window.CSSStyleSheet.prototype.replaceSync) there can be similar function names in JS. https://github.com/search?l=JavaScript&p=1&q=replacesync&type=Code constructible stylesheets have now been enabled on all Firefox channels (May 2022). https://bugzilla.mozilla.org/show_bug.cgi?id=1644102 https://caniuse.com/mdn-api_cssstylesheet_replacesync There is a reasonable usage in between 0.45% and 0.67% https://chromestatus.com/metrics/feature/timeline/popularity/2845 I was very surprised this web standard seems to work everywhere but Safari. https://caniuse.com/mdn-api_cssstylesheet_replacesync My company uses it in combination with const sheet = new CSSStyleSheet() sheet.replaceSync(css) const shadow = el.attachShadow({ mode: 'closed' }) shadow.adoptedStyleSheets = [sheet] to create re-usable components that can be themed and even though the components were created in different contexts by different developers, the default css of each component will never clash with the css of other components. Previously we had to either stricly follow conventions like BEM Or we had to emply css-in-js libraries which prefix or postfix every selector with some sort of short hash to make sure it is unique and doesn't clash. The technique above allows us to not bother anymore with conventions like BEM which work but require a lot of discipline on the side of developers and we also do not need to use css-in-js libraries anymore. Please consider supporting this feature soon :-) *** This bug has been marked as a duplicate of bug 245579 *** |