Closed pstoica closed 9 years ago
https://github.com/Modernizr/Modernizr/pull/1132#issuecomment-49923209
This may not be the best solution? Additionally, @-moz-document
should work, but DOCUMENT_RULE
isn't present.
Some exceptions may need to be made.
nice work @pstoica
Some questions though, please don't take it the wrong way, I just try to maintain this tiny code base in the highest possibly quality ...
It's all good! I'll adjust according to feedback later.
Regarding using window.CSSRule, I started out mapping at-rules to similar properties, did some research, and found this repo (also adapted the code in this PR since it's public domain): https://github.com/ryanmorr/is-rule-supported
Modernizr is also doing something similar. The problem is, it's not 100% accurate (IE problems, Mozilla supports @-moz-document but has no document rule). And like you said, we already know the prefix. Should this stick to CSSRule and add any other conditions/exceptions, or would you prefer something else?
Regarding using window.CSSRule, I started out mapping at-rules to similar properties, did some research, and found this repo (also adapted the code in this PR since it's public domain): https://github.com/ryanmorr/is-rule-supported
yeah saw it too.
Modernizr is also doing something similar. The problem is, it's not 100% accurate (IE problems, Mozilla supports @-moz-document but has no document rule).
yeah I know :)
Which problems except of @document do we know? I think @document is not an issue for any of us :)
Should this stick to CSSRule and add any other conditions/exceptions,
I would stick to an element if it works. If there are issues, then it might be good to know them and reference them as a comment, otherwise I would use element just for the sake of consistency ... basically it doesn't matter. Another thing is CSSRule is implemented in IE since version 9, so element has a higher versions range ...
Yeah, so I figured @keyframes
is really all we care about.. @document
would only go to @-moz-document
or be removed if we really care about supporting it.
I think @keyframes
can just go off of -[prefix]-animation-name
in an element's style. Should we just leave other at-rules untouched?
One more question: does jss-vendor-prefixer leave already prefixed props/values alone? Do I need to account for that here?
I think @keyframes can just go off of -[prefix]-animation-name in an element's style. Should we just leave other at-rules untouched?
For now yes, however css-vendor is a generic utility, if we do any specific checks then in jss-vendor-prefixer.
One more question: does jss-vendor-prefixer leave already prefixed props/values alone? Do I need to account for that here?
It only adds prefix if it won't work without. So here you just need to return the supported name or false.
A I mentioned before: test if passed property works as it is -> if yes return it -> if no add vendor prefix for the current runtime, test again -> if yes - return it -> if no - return false.
And yes if someone will pass -moz-blah in chrome, it won't work we will add -webkit to it, it won't work either, we will return false
So it sounds like in jss-vendor-prefixer we can just:
@keyframes
in rule.selectorsupportedProperty('animation-name')
-webkit-animation-name
back to @-webkit-keyframes
and then we can leave other at-rules alone :smile:
Sound good? If so, close this and let me know if you want me to make those changes to jss-vendor-prefixer.
Not sure I understand what you mean
convert -webkit-animation-name back to @-webkit-keyframes
Sorry, forgot to include some context:
https://developer.mozilla.org/en-US/docs/Web/CSS/@keyframes Mozilla recommends:
To use keyframes, you create a @keyframes rule with a name that is then used by the animation-name property to match an animation to its keyframe list.
We already have your supportedProperty rule working fine for animation-name. It seems better to just reuse that instead of making a new test that 1) isn't that accurate and 2) checks for stuff we don't care about, we just need @keyframes
.
ok so lets discuss again in jss-vendor-prefixer what needs to be done as a separate issue there .... :)
looks like we want to close this pr, right?
Sounds good!
just added keyframes prefixing in https://github.com/jsstyles/jss-vendor-prefixer
This is in support of the first item at jsstyles/jss-vendor-prefixer#1
A corresponding PR for that library will follow that will update the selector using the result from supportedSelector.