Skip to content
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

Merged
merged 4 commits into from
Dec 1, 2015

Commits on Nov 27, 2015

  1. Allow replacing stylesheet to preserve the cascade

    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.
    henrahmagix committed Nov 27, 2015
    Configuration menu
    Copy the full SHA
    6339f5c View commit details
    Browse the repository at this point in the history

Commits on Dec 1, 2015

  1. Fix other media types using "all" media type.

    Bug was introduced when DRYing code to the `insertCss` function.
    henrahmagix committed Dec 1, 2015
    Configuration menu
    Copy the full SHA
    5eda5f7 View commit details
    Browse the repository at this point in the history
  2. Fix replaceStartIndex === -1 replace bug.

    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`.
    henrahmagix committed Dec 1, 2015
    Configuration menu
    Copy the full SHA
    807eda5 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    e485fe7 View commit details
    Browse the repository at this point in the history