Opened 15 years ago
Closed 13 years ago
#3039 closed bug (fixed)
Older Safari versions crash in makeArray
Reported by: | kloor | Owned by: | flesler |
---|---|---|---|
Priority: | minor | Milestone: | 1.4 |
Component: | core | Version: | 1.4a1 |
Keywords: | safari 2 | Cc: | kloor, mnash |
Blocked by: | Blocking: |
Description
The attached test case consistently crashes older versions of Safari. This appears due to the following line makeArray: http://dev.jquery.com/browser/trunk/jquery/src/core.js?rev=5700#L1134
jQuery version 1.2.3 does not crash.
Attachments (1)
Change History (14)
Changed 15 years ago by
Attachment: | index.html added |
---|
comment:1 Changed 15 years ago by
Keywords: | safari 2 added |
---|---|
Priority: | major → minor |
comment:2 Changed 15 years ago by
We've run into this problem as well with jQuery 1.2.6 and Safari 2.0.4. Confirmed that reverting to the definition of makeArray in 1.2.3 fixes the problem.
comment:3 Changed 15 years ago by
Owner: | set to flesler |
---|---|
Status: | new → assigned |
Ok, will check this out for 1.3.
comment:4 Changed 14 years ago by
In version 1.2.3, the code has a comment: Need to use typeof to fight Safari childNodes crashes
if ( typeof array != "array" )
After swapping out in 1.2.6 line 1131 - "if( array != null ){" with the above code - Safari no longer crashes and all the other browsers work.
comment:5 follow-ups: 6 7 Changed 14 years ago by
Cc: | kloor added |
---|
That's not a compatible replacement. Try
if ( typeof array != "undefined" )
comment:7 Changed 14 years ago by
That fixes the test case I posted, but it still crashes for actual script. I think the crash is caused by the if statement on line 1134, it's just that we prevented Safari from reaching that line for the test case.
I'll have to look into developing another test case.
comment:8 Changed 14 years ago by
Cc: | mnash added |
---|
Can you try using the most recent version from the trunk (revision 5289 I think) Try with and without the replacement I mentioned.
Thanks
comment:9 Changed 14 years ago by
I have tried the test case against jQuery (Rev: 5829) on Safari 2.0.4 and it still crashes.
comment:10 Changed 14 years ago by
We still haven't been able to upgrade past jQuery 1.2.3 at The Onion because of this bug; a non-negligible portion of our audience is still on Safari 2.
comment:11 Changed 14 years ago by
I found that calling array.setInterval actually caused the crash.
So I modified the method as follows and ran the test case (I couldn't find a better way of debugging in Safari 2).
makeArray: function( array ) { var ret = []; if( array != null ){ k += typeof array + ","; } return ret; },
On Firefox, the variable k contained object,object,object,.
On Safari, the variable k contained object,function,object,.
I have no idea what causes the difference and why it crashes Safari 2, but adding a simple type check could be a temporary workaround.
For revision 5829.
makeArray: function( array ) { var ret = []; if( array != null ){ var i = array.length; // The window, strings (and functions) also have 'length' if( i == null || typeof array == 'string' || (typeof array != 'function' && array.setInterval) ) ret[0] = array; else while( i ) ret[--i] = array[i]; } return ret; },
For jQuery 1.2.6.
makeArray: function( array ) { var ret = []; if( array != null ){ var i = array.length; //the window, strings and functions also have 'length' if( i == null || ( typeof array != 'function' && ( array.split || array.setInterval || array.call ) ) ) ret[0] = array; else while( i ) ret[--i] = array[i]; } return ret; },
Hope this helps you fix the issue.
comment:12 Changed 14 years ago by
I have found a page explaining the issue. http://mootools.lighthouseapp.com/projects/2706-mootools/tickets/37
comment:16 Changed 13 years ago by
Milestone: | 1.3 → 1.4 |
---|---|
Resolution: | → fixed |
Status: | assigned → closed |
Version: | 1.2.6 → 1.4a1 |
Test Case