ability to retrieve uncomputed styles in IE<9, fixes #10796#610
ability to retrieve uncomputed styles in IE<9, fixes #10796#610mikesherov wants to merge 3 commits intojquery:masterfrom
Conversation
src/css.js
Outdated
There was a problem hiding this comment.
Unfortunately, rnumnopx fails to recognize real-number values like "4.2%" and explicit positive values like "+1ex" (the latter flaw shared with rnumpx), and gives a false positive on "1em center". Sticking with the "!numpx && numnopx" approach, you could define rnumnopx = /^[-+]?\d*(?:\d|\.\d+)(?!px)[^\d\s]+$/, but I think it might be better to define rnum = /^[-+]?\d*(?:\d|\.\d+)([^\d\s]+)?$/ (capturing the units at index 1) and then use ( ( rnum.exec( ret ) || [] )[1] || "px" ) !== "px" (passing only if rnum matches and units are non-px) in place of the test on line 300.
Sorry if that doesn't help with your "less complex" request.
http://www.w3.org/TR/CSS21/syndata.html#numbers
http://www.w3.org/TR/CSS21/colors.html#propdef-background-position
There was a problem hiding this comment.
This is great! Thanks for the help.
There was a problem hiding this comment.
Thinking about this further, we can take hybrid approach: one regex
without having to capture that looks for number followed by a string
that isn't px and contains no spaces followed by end of string.
Sent Via Mobile: Please excuse my grammar, tone, and punctuation. My
thumbs can't create flowery prose.
On Nov 20, 2011, at 5:38 AM, Richard Gibson
reply@reply.github.com
wrote:
@@ -5,7 +5,7 @@ var ralpha = /alpha([^)]*)/i,
// fixed for IE9, see #8346
rupper = /([A-Z]|^ms)/g,
rnumpx = /^-?\d+(?:px)?$/i,
- rnum = /^-?\d/,
- rnumnopx = /^-?\d+(?!px)[^\d]+$/i,
Unfortunately,
rnumnopxfails to recognize real-number values like "4.2%" and explicit positive values like "+1ex" (the latter flaw shared withrnumpx), and gives a false positive on "1em center". Sticking with the "!numpx && numnopx" approach, you could definernumnopx = /^[-+]?\d*(?:\d|\.\d+)(?!px)[^\d\s]+$/, but I think it might be better to definernum = /^[-+]?\d*(?:\d|\.\d+)([^\d\s]+)?$/(capturing the units at index 1) and then use( ( rnum.exec( ret ) || [] )[1] || "px" ) !== "px"(passing only ifrnummatches and units are non-px) in place of the test on line 300.Sorry if that doesn't help with your "less complex" request.
http://www.w3.org/TR/CSS21/syndata.html#numbers
http://www.w3.org/TR/CSS21/colors.html#propdef-background-position
Reply to this email directly or view it on GitHub:
https://github.com/jquery/jquery/pull/610/files#r241007
There was a problem hiding this comment.
My pleasure. I like the hybrid idea of independently using "number (pixels)" and "number (non pixels)" regular expressions.
|
@gibson042, I went ahead and used our combined approach by making it into 1 regex. Thanks! Regarding "+12em", IE doesn't report the "+" sign there for that hack, so I don't need to check for it. Also, regarding "12.2em", the goal of this PR wasn't to fix the cases were "12.2em" WASN'T getting converted to equivalent pixels, so I'll save THAT exercise for another day. |
|
for those curious: if we got rid of Dean Edwards awesome hack: |
|
I'm totally new to this process, but understand the benefit of focused commits. Should I open a ticket for the currentStyle function's inability to recognize non-integer numeric values? |
|
Sure, you should head on over to bugs.jquery.com and follow the instructions for submitting a bug there. After that, you can submit a pull request that fixes the bug. See here for more info: http://docs.jquery.com/Getting_Involved and also read the readme here: https://github.com/jquery/jquery |
|
@gibson042, you can also head over the the #jquery-dev irc channel for more guidance: http://webchat.freenode.net/?channels=jquery-dev |
|
Hmm... the old test was only on "starts like a number", so the issue with real-number values won't manifest until after this PR is integrated. I think it should be addressed now. |
|
@gibson042, please submit a bug outlining the issue. Then we can work on some unit tests in another PR based off of this. |
|
http://jsperf.com/2011-11-23-regexp-complexity |
|
Fair enough, I'll roll your change in then. |
|
Upon reading the jsperf documentation, it turns out that I misunderstood http://jsperf.com/2011-11-23-regexp-complexity Sorry about so much attention on a minor issue, and big thanks for taking me under your wing. |
|
Probably better to build a copy of jQuery that has your new regex in Sent Via Mobile: Please excuse my grammar, tone, and punctuation. My On Nov 24, 2011, at 1:31 PM, Richard Gibson
|
|
http://jsperf.com/2011-11-23-regexp-complexity/2 Assuming I've set up the tests correctly, there is approximately a 4% difference in I recommend using the shortest of the three decimal-accepting expressions, which also tested fastest: |
|
@gibson042, let's move this conversation over to the trac ticket for the issue you raised. At this point, it's way off topic. |
|
Landed. 6aa4095 |
But seriously, I suck at them. Please let me know if there is a less complex regex that fixes this bug.