Created
July 11, 2012 02:03
-
-
Save andrewplummer/3087484 to your computer and use it in GitHub Desktop.
Dragonfly bug?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Coming in: | |
| // | |
| // weekday = 40; | |
| // d = new Date(2012, 1, 1); | |
| // utc = false; | |
| // prefer = 1; | |
| // callDateMethod with those arguments is equivalent to "d.getDay()" and will return 3; | |
| // When the bug occurs, weekday will become 47, where in every other browser it should remain 40 as: | |
| // callDateMethod(...) IS 3 AND 40 % 7 IS 5 | |
| // 3 - 5 IS -2 | |
| // -2 < 0 IS true | |
| // prefer === 1 IS true | |
| // true === true SO | |
| // 0 * 1 * 7 = 0 | |
| // 40 += 0 = 40 | |
| // console.log on each of these parenthetical statements will always produce the same result in all browsers, | |
| // no discrepancy. It only triggers on the full line, (my fix was splitting up the statement, which it should | |
| // have been anyway... the fact that all the "parts" are ok makes me guess it may be a parsing bug) | |
| // There are 12 unit tests that run through this code before the final test triggers the bug. | |
| // If ANY ONE of those test are removed it will not trigger. | |
| // If Dragonfly is open it will not trigger. | |
| // If the same line is logged one line above it will not trigger: | |
| // console.log(((callDateMethod(d, 'get', utc, 'Day') - (weekday % 7) < 0) === (prefer === 1) ? 0 : 1) * prefer * 7); | |
| weekday += ((callDateMethod(d, 'get', utc, 'Day') - (weekday % 7) < 0) === (prefer === 1) ? 0 : 1) * prefer * 7; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment