Ticket #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 |
| Blocking: | Blocked by: |
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
Change History
Changed 5 years ago by kloor
-
attachment
index.html
added
comment:1 Changed 5 years ago by flesler
- Keywords safari 2 added
- Priority changed from major to minor
comment:2 Changed 5 years ago by lukemelia
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 5 years ago by flesler
- Owner set to flesler
- Status changed from new to assigned
Ok, will check this out for 1.3.
comment:4 Changed 5 years ago by mnash
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 5 years ago by flesler
- Cc kloor added
That's not a compatible replacement. Try
if ( typeof array != "undefined" )
comment:7 in reply to: ↑ 5 Changed 5 years ago by kloor
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 5 years ago by flesler
- 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 5 years ago by harawata
I have tried the test case against jQuery (Rev: 5829) on Safari 2.0.4 and it still crashes.
comment:10 Changed 5 years ago by korpios
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 5 years ago by harawata
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 5 years ago by harawata
I have found a page explaining the issue. http://mootools.lighthouseapp.com/projects/2706-mootools/tickets/37
comment:16 Changed 3 years ago by john
- Status changed from assigned to closed
- Version changed from 1.2.6 to 1.4a1
- Resolution set to fixed
- Milestone changed from 1.3 to 1.4
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

Test Case