mirror of
https://github.com/jquery/jquery.git
synced 2024-11-23 02:54:22 +00:00
Added a fix for IE returning comment nodes in * queries. I put the logic in $.merge() but added a conditional such that the speed hit only effects IE users. (Bug #1155)
This commit is contained in:
parent
735e2e8197
commit
24db022ba0
9
src/jquery/jquery.js
vendored
9
src/jquery/jquery.js
vendored
@ -1725,8 +1725,17 @@ jQuery.extend({
|
|||||||
merge: function(first, second) {
|
merge: function(first, second) {
|
||||||
// We have to loop this way because IE & Opera overwrite the length
|
// We have to loop this way because IE & Opera overwrite the length
|
||||||
// expando of getElementsByTagName
|
// expando of getElementsByTagName
|
||||||
|
|
||||||
|
// Also, we need to make sure that the correct elements are being returned
|
||||||
|
// (IE returns comment nodes in a '*' query)
|
||||||
|
if ( jQuery.browser.msie ) {
|
||||||
|
for ( var i = 0; second[i]; i++ )
|
||||||
|
if ( second[i].nodeType != 8 )
|
||||||
|
first.push(second[i]);
|
||||||
|
} else
|
||||||
for ( var i = 0; second[i]; i++ )
|
for ( var i = 0; second[i]; i++ )
|
||||||
first.push(second[i]);
|
first.push(second[i]);
|
||||||
|
|
||||||
return first;
|
return first;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -1,8 +1,13 @@
|
|||||||
module("selector");
|
module("selector");
|
||||||
|
|
||||||
test("element", function() {
|
test("element", function() {
|
||||||
expect(8);
|
expect(9);
|
||||||
ok( $("*").size() >= 30, "Select all" );
|
ok( $("*").size() >= 30, "Select all" );
|
||||||
|
var all = $("*"), good = true;
|
||||||
|
for ( var i = 0; i < all.length; i++ )
|
||||||
|
if ( all[i].nodeType == 8 )
|
||||||
|
good = false;
|
||||||
|
ok( good, "Select all elements, no comment nodes" );
|
||||||
t( "Element Selector", "p", ["firstp","ap","sndp","en","sap","first"] );
|
t( "Element Selector", "p", ["firstp","ap","sndp","en","sap","first"] );
|
||||||
t( "Element Selector", "body", ["body"] );
|
t( "Element Selector", "body", ["body"] );
|
||||||
t( "Element Selector", "html", ["html"] );
|
t( "Element Selector", "html", ["html"] );
|
||||||
|
Loading…
Reference in New Issue
Block a user