-
Notifications
You must be signed in to change notification settings - Fork 18
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
Capture dynamically inserted CSS rules #45
Comments
I was about to report this (as I keep running into it a lot) and turns out there is already an issue. I was wondering if capturing styling by serializing I think this also has benefit of not needing to deal with import rules and etc.. as I believe imported sheets would also be listed. |
Alternative strategy might be to inline all the styles into elements themselves by obtaining those through |
Yes, something to be tried out. I have not investigated how rich the CSSOM is, i.e. whether it lets us easily serialise the stylesheet again to get a string; ideally it would have (or we could create) an equivalent of If we could always use the CSSOM, we could even remove the hassle with (and dependency on) post-css, which is now used to parse stylesheets in extract-links/from-css.js. But as you say, we may need to fall back to fetching the contents, if the rules cannot be accessed through the CSSOM. Similar to how we deal with frames. |
You mean we would, for example, create two However, this approach would also manipulate the DOM unnecessarily. For various use cases, keeping things as equal as possible is desirable (e.g. for archiving or to keep xpath pointers intact). Moreover, some tricks would be needed to fix semantics; for example, if an stylesheet So I would probably opt to just leave the import structure intact. I do not see a difficulty in dealing with import rules (they have a By the way, one reason for reading |
I don't have specifics I just noticed that there is
Which seems to imply that imported sheets would also be in the I guess you don't necessarily need to create link elements for imported sheets. Imported sheets could be just serialized and and import rule could be updated instead. |
Scripts can modify stylesheets using the CSSOM functions like
CSSStylesheet.insertRule()
, used by e.g. emotion.js.The contents of a
<style>
element appear to not be updated to reflect the new rules, so I suppose we will thus have to do this ourselves, by going through the rules using CSSOM. Or we take another approach altogether to preserve styles.In the wild, I observed the problem with images on NYTimes articles, which become a mess (they use emotion.js).
The text was updated successfully, but these errors were encountered: