-
Notifications
You must be signed in to change notification settings - Fork 20.6k
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
The compatibility of different browsers should be considered about test case css(--customProperty) #4926
Comments
Thanks for the report. There was a recent spec change that require CSS Custom Properties values to be trimmed and it's just been implemented in Firefox 91 so far. I expect it to take some time to roll out to all supported browsers, especially Safari so maybe we should, indeed, trim it until all supported browsers adjust. It sounds easy enough to do, just trim the value. BTW, Firefox behavior is still buggy as it only trims leading spaces and leaves trailing spaces as they are, they have a bug for this: https://bugzilla.mozilla.org/show_bug.cgi?id=1728165. Would you like to try to submit a fix by yourself? |
BTW, we have tests for whitespace handling of CSS Custom Properties (a.k.a. CSS Variables) and the Firefox 91 change is why our Travis tests are failing: https://app.travis-ci.com/github/jquery/jquery/jobs/535647620 |
I'm in favor of trimming if that's what all browsers will do eventually. |
@mgol Thanks for the quick response.
Yes, so in my option, test case css(--customProperty) is more appropriate to be modified to |
@fecore1 Yes, that sounds correct. Would you like to submit a PR with such a change? |
@fecore1 Hey, since this breaks our CI, we'd rather have it fixed quickly. If you're not signing up to provide a PR, that's fine, but it'd be nice if you made it clear. So far I asked twice but you haven't replied. |
@mgol Sorry for the late reply because I'm on a business trip these days. I will try to provide a fix PR |
@fecore1 Cool! Let me know if you need any help. |
The spec has recently changed and CSS Custom Properties values are trimmed now. This change makes jQuery polyfill that new behavior for all browsers. Ref w3c/csswg-drafts#774 Fixes gh-4926 Closes gh-4930
The spec has recently changed and CSS Custom Properties values are trimmed now. This change makes jQuery polyfill that new behavior for all browsers. Ref w3c/csswg-drafts#774 Fixes jquerygh-4926 Closes jquerygh-4930 (partially cherry picked from efadfe9)
The original logic from PR jquerygh-4930 re-used the `rtrim` regex from the selector module but selectors have special escaping rules which means whitespace following a backslash character would not get trimmed. This change splits the logic at the unfortunate but necessary cost of size. Ref jquerygh-4926 Ref jquerygh-4930
The spec has recently changed and CSS Custom Properties values are trimmed now. This change makes jQuery polyfill that new behavior for all browsers. Ref w3c/csswg-drafts#774 Fixes jquerygh-4926 Closes jquerygh-4930 Closes jquerygh-4936 (partially cherry picked from efadfe9)
Link to that spec change issue: w3c/csswg-drafts#774 |
Reopening until we discuss whether the currently landed solution is complete or if it needs more iterations and until we cherry-pick the change to |
The spec has recently changed and CSS Custom Properties values are trimmed now. This change makes jQuery polyfill that new behavior for all browsers. Ref w3c/csswg-drafts#774 Fixes gh-4926 Closes gh-4930 (partially cherry picked from commit efadfe9)
We settled on leaving the current solution as-is. We thought there are some issues with using the wrong CSS whitespace type but it looks like it works just fine. The PR landed on Thanks, @fecore1! |
The original logic from PR jquerygh-4930 re-used the `rtrim` regex from the selector module but selectors have special escaping rules which means whitespace following a backslash character would not get trimmed. This change splits the logic at the unfortunate but necessary cost of size. Ref jquerygh-4926 Ref jquerygh-4930
The original logic from PR jquerygh-4930 re-used the `rtrim` regex from the selector module but selectors have special escaping rules which means whitespace following a backslash character would not get trimmed. This change splits the logic at the unfortunate but necessary cost of size. Ref jquerygh-4926 Ref jquerygh-4930
…erties The original logic from PR jquerygh-4930 re-used the `rtrim` regex from the selector module but selectors have special escaping rules which means whitespace following a backslash character would not get trimmed. This change splits the logic at the unfortunate but necessary cost of size. Ref jquerygh-4926 Ref jquerygh-4930
Description
The compatibility of different browsers should be considered about test case css(--customProperty)
$elem.css( "--prop2" )
has different val on different browsers:$elem.css( "--prop2" ) => 'val2'
$elem.css( "--prop2" ) => ' val2'
$elem.css( "--prop2" ) => ' val2'
As i know,
jQuery.css
is based ongetComputedStyle
andgetPropertyValue
, and that have different behaves on different browsers.Link to test case
Please open test case bellow use different browsers and attention the value of
--prop2
https://codepen.io/fecore1/pen/KKqNxQx
The text was updated successfully, but these errors were encountered: