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

Make String Handlers Use useImportant #256

Merged
merged 1 commit into from
Jul 14, 2017
Merged

Conversation

jeresig
Copy link
Member

@jeresig jeresig commented Jul 14, 2017

The string handlers were always inserting rules with no !important, rather than respecting the settings specified by the library. This updates the string handlers to receive an additional useImportant argument, which is then passed down to the various places that need it (rather than just passing false). I updated the existing test, which was confirming the wrong input, and also added some more tests to no-important_test.js to confirm that it was still being disabled.

In practice this helps to fix the issue where Firefox makes it impossible to override CSS that has !important with an animation, unless the animation is, also, using !important:
http://tosbourn.com/firefox-honours-important-in-css-animations-no-one-else-seems-to/

Test Plan:
I ran npm test and it passed.

The string handlers were always inserting rules with no `!important`, rather than respecting the settings specified by the library. This updates the string handlers to receive an additional `useImportant` argument, which is then passed down to the various places that need it (rather than just passing `false`). I updated the existing test, which was confirming the wrong input, and also added some more tests to `no-important_test.js` to confirm that it was still being disabled.

In practice this helps to fix the issue where Firefox makes it impossible to override CSS that has `!important` with an animation, unless the animation is, also, using `!important`:
http://tosbourn.com/firefox-honours-important-in-css-animations-no-one-else-seems-to/

Test Plan:
I ran `npm test` and it passed.
@jeresig jeresig requested a review from xymostech July 14, 2017 18:58
Copy link
Contributor

@xymostech xymostech left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code looks good to me! Pretty simple to see the flow here. :) I guess we just never did this before because we weren't sure it was important?

In practice this helps to fix the issue where Firefox makes it impossible to override CSS that has !important with an animation, unless the animation is, also, using !important:

Huh, what an interesting effect. Looking now, I would have expected that would happen everywhere, but CSS is strange, so oh well.


assertStylesInclude('font-family:"CoolFont",sans-serif');
assertStylesInclude('font-family:CoolFont;');
assertStylesInclude("src:url('coolfont.ttf');");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great tests!

@jeresig jeresig merged commit 8a5afdf into master Jul 14, 2017
@lencioni lencioni deleted the string-handlers-important branch September 12, 2017 17:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants