Added a number of additional speed gains (we now hold our own against Dojo and DOMQuery), touched up some of the selector code, fixed some minor bugs, fixed a bug with triggerEvent in Opera, fixed some more test case bugs.
This commit is contained in:
parent
3446c3af76
commit
9c94ef4c41
4 changed files with 868 additions and 863 deletions
|
@ -264,13 +264,12 @@ function equals(expected, actual, message) {
|
||||||
* @param String type
|
* @param String type
|
||||||
*/
|
*/
|
||||||
function triggerEvent( elem, type, event ) {
|
function triggerEvent( elem, type, event ) {
|
||||||
if ( jQuery.browser.mozilla ) {
|
if ( jQuery.browser.mozilla || jQuery.browser.opera ) {
|
||||||
event = document.createEvent("MouseEvents");
|
event = document.createEvent("MouseEvents");
|
||||||
event.initMouseEvent(type, true, true, elem.ownerDocument.defaultView,
|
event.initMouseEvent(type, true, true, elem.ownerDocument.defaultView,
|
||||||
0, 0, 0, 0, 0, false, false, false, false, 0, null);
|
0, 0, 0, 0, 0, false, false, false, false, 0, null);
|
||||||
elem.dispatchEvent( event );
|
elem.dispatchEvent( event );
|
||||||
} else if ( jQuery.browser.msie || jQuery.browser.opera ) {
|
} else if ( jQuery.browser.msie ) {
|
||||||
event = document.createEventObject();
|
elem.fireEvent("on"+type);
|
||||||
elem.fireEvent("on"+type, event);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
1662
src/jquery/coreTest.js
vendored
1662
src/jquery/coreTest.js
vendored
File diff suppressed because it is too large
Load diff
1
src/jquery/jquery.js
vendored
1
src/jquery/jquery.js
vendored
|
@ -1630,7 +1630,6 @@ jQuery.extend({
|
||||||
// expando of getElementsByTagName
|
// expando of getElementsByTagName
|
||||||
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;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -154,11 +154,10 @@ jQuery.extend({
|
||||||
|
|
||||||
if ( m ) {
|
if ( m ) {
|
||||||
// Perform our own iteration and filter
|
// Perform our own iteration and filter
|
||||||
jQuery.each( ret, function(){
|
for ( var i = 0; ret[i]; i++ )
|
||||||
for ( var c = this.firstChild; c; c = c.nextSibling )
|
for ( var c = ret[i].firstChild; c; c = c.nextSibling )
|
||||||
if ( c.nodeType == 1 && ( jQuery.nodeName(c, m[1]) || m[1] == "*" ) )
|
if ( c.nodeType == 1 && ( m[1] == "*" || jQuery.nodeName(c, m[1]) ) )
|
||||||
r.push( c );
|
r.push( c );
|
||||||
});
|
|
||||||
|
|
||||||
ret = r;
|
ret = r;
|
||||||
t = t.replace( re, "" );
|
t = t.replace( re, "" );
|
||||||
|
@ -166,7 +165,7 @@ jQuery.extend({
|
||||||
foundToken = true;
|
foundToken = true;
|
||||||
} else {
|
} else {
|
||||||
// Look for pre-defined expression tokens
|
// Look for pre-defined expression tokens
|
||||||
for ( var i = 0; i < jQuery.token.length; i += 2 ) {
|
for ( var i = 0, tl = jQuery.token.length; i < tl; i += 2 ) {
|
||||||
// Attempt to match each, individual, token in
|
// Attempt to match each, individual, token in
|
||||||
// the specified order
|
// the specified order
|
||||||
var re = jQuery.token[i], fn = jQuery.token[i+1];
|
var re = jQuery.token[i], fn = jQuery.token[i+1];
|
||||||
|
@ -236,10 +235,9 @@ jQuery.extend({
|
||||||
// Do a quick check for node name (where applicable) so
|
// Do a quick check for node name (where applicable) so
|
||||||
// that div#foo searches will be really fast
|
// that div#foo searches will be really fast
|
||||||
ret = r = oid && (!m[3] || jQuery.nodeName(oid, m[3])) ? [oid] : [];
|
ret = r = oid && (!m[3] || jQuery.nodeName(oid, m[3])) ? [oid] : [];
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// We need to find all descendant elements
|
// We need to find all descendant elements
|
||||||
for ( var i = 0, rl = ret.length; i < rl; i++ ) {
|
for ( var i = 0; ret[i]; i++ ) {
|
||||||
// Grab the tag name being searched for
|
// Grab the tag name being searched for
|
||||||
var tag = m[1] != "" || m[0] == "" ? "*" : m[2];
|
var tag = m[1] != "" || m[0] == "" ? "*" : m[2];
|
||||||
|
|
||||||
|
@ -252,23 +250,20 @@ jQuery.extend({
|
||||||
|
|
||||||
// It's faster to filter by class and be done with it
|
// It's faster to filter by class and be done with it
|
||||||
if ( m[1] == "." )
|
if ( m[1] == "." )
|
||||||
r = jQuery.grep( r, function(e) {
|
r = jQuery.classFilter( r, m[2] );
|
||||||
return jQuery.className.has(e, m[2]);
|
|
||||||
});
|
|
||||||
|
|
||||||
// Same with ID filtering
|
// Same with ID filtering
|
||||||
if ( m[1] == "#" ) {
|
if ( m[1] == "#" ) {
|
||||||
// Remember, then wipe out, the result set
|
var tmp = [];
|
||||||
var tmp = r;
|
|
||||||
r = [];
|
|
||||||
|
|
||||||
// Then try to find the element with the ID
|
// Try to find the element with the ID
|
||||||
jQuery.each( tmp, function(){
|
for ( var i = 0; r[i]; i++ )
|
||||||
if ( this.getAttribute("id") == m[2] ) {
|
if ( r[i].getAttribute("id") == m[2] ) {
|
||||||
r = [ this ];
|
tmp = [ r[i] ];
|
||||||
return false;
|
break;
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
r = tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = r;
|
ret = r;
|
||||||
|
@ -303,6 +298,17 @@ jQuery.extend({
|
||||||
return done;
|
return done;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
classFilter: function(r,m,not){
|
||||||
|
m = " " + m + " ";
|
||||||
|
var tmp = [];
|
||||||
|
for ( var i = 0; r[i]; i++ ) {
|
||||||
|
var pass = (" " + r[i].className + " ").indexOf( m ) >= 0;
|
||||||
|
if ( !not && pass || not && !pass )
|
||||||
|
tmp.push( r[i] );
|
||||||
|
}
|
||||||
|
return tmp;
|
||||||
|
},
|
||||||
|
|
||||||
filter: function(t,r,not) {
|
filter: function(t,r,not) {
|
||||||
var last;
|
var last;
|
||||||
|
|
||||||
|
@ -312,11 +318,8 @@ jQuery.extend({
|
||||||
|
|
||||||
var p = jQuery.parse, m;
|
var p = jQuery.parse, m;
|
||||||
|
|
||||||
jQuery.each( p, function(i,re){
|
for ( var i = 0; p[i]; i++ ) {
|
||||||
|
m = p[i].exec( t );
|
||||||
// Look for, and replace, string-like sequences
|
|
||||||
// and finally build a regexp out of it
|
|
||||||
m = re.exec( t );
|
|
||||||
|
|
||||||
if ( m ) {
|
if ( m ) {
|
||||||
// Remove what we just matched
|
// Remove what we just matched
|
||||||
|
@ -328,18 +331,22 @@ jQuery.extend({
|
||||||
|
|
||||||
m[2] = m[2].replace(/\\/g, "");
|
m[2] = m[2].replace(/\\/g, "");
|
||||||
|
|
||||||
return false;
|
break;
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
|
||||||
if ( !m )
|
if ( !m )
|
||||||
continue;
|
break;
|
||||||
|
|
||||||
// :not() is a special case that can be optimized by
|
// :not() is a special case that can be optimized by
|
||||||
// keeping it out of the expression list
|
// keeping it out of the expression list
|
||||||
if ( m[1] == ":" && m[2] == "not" )
|
if ( m[1] == ":" && m[2] == "not" )
|
||||||
r = jQuery.filter(m[3], r, true).r;
|
r = jQuery.filter(m[3], r, true).r;
|
||||||
|
|
||||||
|
// We can get a big speed boost by filtering by class here
|
||||||
|
else if ( m[1] == "." )
|
||||||
|
r = jQuery.classFilter(r, m[2], not);
|
||||||
|
|
||||||
// Otherwise, find the expression to execute
|
// Otherwise, find the expression to execute
|
||||||
else {
|
else {
|
||||||
var f = jQuery.expr[m[1]];
|
var f = jQuery.expr[m[1]];
|
||||||
|
|
Loading…
Add table
Reference in a new issue