-
Notifications
You must be signed in to change notification settings - Fork 0
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
Allow replacing stylesheet to preserve the cascade #1
Conversation
So what is this, a fork you want to push back? |
Yes.
Darn, I forgot that I branched off |
This pull-request is first for internal review, then when in |
5e3b8e0
to
19b021c
Compare
Usually this library will append media queries in separate <style> elements. However, doing this changes the cascade such that a media rule will be used over a non-media rule. This is because the media rule is removed from its position and appended after everything else. It is a common case that a non-media rule will override a media rule, so this inversion of the cascade makes it very difficult to style for all browsers using this polyfill. Turn on this option by setting `window.RESPOND_REPLACE_STYLES = true` before sourcing this script. It will remove every stylesheet it finds and move all CSS into the `media="all"` stylesheet that is appended, minus the inactive media query rules and those of other media types, like print. The other types are appended in the usual manner.
19b021c
to
6339f5c
Compare
@wytrych Fixed, ready for review |
Bug was introduced when DRYing code to the `insertCss` function.
As a result of rebasing the `RESPOND_REPLACE_STYLES` option code onto 1c8ce14 (after previously being on 1.4.2), the replace index was being calculated as -1, meaning the query could not be found in the total styles. This was because comments are now being stripped. To fix that, the stripping of comments and keyframes from styles are done immediately in the `translate` function, and then stored with their replaced urls if `RESPOND_REPLACE_STYLES === true`.
@wytrych I introduced two bugs in the rebase. They're fixed now. I was sure I had tested it, but I must have not been using the rebased code when testing in a project. |
There's an awful lot of code here in a library I have no knowledge of :( I'm not sure I can spot anything useful, getting to know the code would take me a lot of time. |
I can explain it for you in person if that helps? |
That would basically mean running through the code, which still takes a lot of time |
It'll be 5 minutes of explanation of the gist and a bit of detail regarding the changes here, then another 5-10 of answering questions you have. |
ok after lunch? |
👍 |
Allow replacing stylesheet to preserve the cascade
Thanks! |
@incuna/js Please review, ta! The files to review are
README.md
andsrc/respond.js
; the two*.src.js
files are autocompiled fromsrc/respond.js
.This fixes scottjehl#325