Changeset 1596
- Timestamp:
- 03/26/07 02:06:50 (2 years ago)
- Location:
- trunk/jquery
- Files:
-
- 4 modified
-
build/test/data/testrunner.js (modified) (1 diff)
-
src/jquery/coreTest.js (modified) (2 diffs)
-
src/jquery/jquery.js (modified) (1 diff)
-
src/selector/selector.js (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/jquery/build/test/data/testrunner.js
r1592 r1596 265 265 */ 266 266 function triggerEvent( elem, type, event ) { 267 if ( jQuery.browser.mozilla ) {267 if ( jQuery.browser.mozilla || jQuery.browser.opera ) { 268 268 event = document.createEvent("MouseEvents"); 269 269 event.initMouseEvent(type, true, true, elem.ownerDocument.defaultView, 270 270 0, 0, 0, 0, 0, false, false, false, false, 0, null); 271 271 elem.dispatchEvent( event ); 272 } else if ( jQuery.browser.msie || jQuery.browser.opera ) { 273 event = document.createEventObject(); 274 elem.fireEvent("on"+type, event); 275 } 276 } 272 } else if ( jQuery.browser.msie ) { 273 elem.fireEvent("on"+type); 274 } 275 } -
trunk/jquery/src/jquery/coreTest.js
r1592 r1596 345 345 $('#check1').click(function() { 346 346 var checkbox = this; 347 ok( !checkbox.checked, "Checkbox's state is erased after wrap() action, see #769" );347 ok( checkbox.checked, "Checkbox's state is erased after wrap() action, see #769" ); 348 348 $(checkbox).wrap( '<div id="c1" style="display:none;"></div>' ); 349 ok( !checkbox.checked, "Checkbox's state is erased after wrap() action, see #769" );349 ok( checkbox.checked, "Checkbox's state is erased after wrap() action, see #769" ); 350 350 // use a fade in to check state after this event handler has finished 351 $("#c1").fadeIn(function() {352 ok( checkbox.checked, "Checkbox's state is erased after wrap() action, see #769" );351 setTimeout(function() { 352 ok( !checkbox.checked, "Checkbox's state is erased after wrap() action, see #769" ); 353 353 start(); 354 } );354 }, 100); 355 355 }).click(); 356 356 }); … … 693 693 isSet( $("#sndp").siblings("[code]").get(), q("sap"), "Check for filtered siblings (has code child element)" ); 694 694 isSet( $("#sndp").siblings("[a]").get(), q("en", "sap"), "Check for filtered siblings (has anchor child element)" ); 695 isSet( $("#foo").siblings("form, b").get(), q("form", " floatTest"), "Check for multiple filters" );695 isSet( $("#foo").siblings("form, b").get(), q("form", "lengthtest", "floatTest"), "Check for multiple filters" ); 696 696 }); 697 697 -
trunk/jquery/src/jquery/jquery.js
r1594 r1596 1631 1631 for ( var i = 0; second[i]; i++ ) 1632 1632 first.push(second[i]); 1633 1634 1633 return first; 1635 1634 }, -
trunk/jquery/src/selector/selector.js
r1595 r1596 155 155 if ( m ) { 156 156 // Perform our own iteration and filter 157 jQuery.each( ret, function(){158 for ( var c = this.firstChild; c; c = c.nextSibling )159 if ( c.nodeType == 1 && ( jQuery.nodeName(c, m[1]) || m[1] == "*") )157 for ( var i = 0; ret[i]; i++ ) 158 for ( var c = ret[i].firstChild; c; c = c.nextSibling ) 159 if ( c.nodeType == 1 && ( m[1] == "*" || jQuery.nodeName(c, m[1]) ) ) 160 160 r.push( c ); 161 });162 161 163 162 ret = r; … … 167 166 } else { 168 167 // Look for pre-defined expression tokens 169 for ( var i = 0 ; i < jQuery.token.length; i += 2 ) {168 for ( var i = 0, tl = jQuery.token.length; i < tl; i += 2 ) { 170 169 // Attempt to match each, individual, token in 171 170 // the specified order … … 237 236 // that div#foo searches will be really fast 238 237 ret = r = oid && (!m[3] || jQuery.nodeName(oid, m[3])) ? [oid] : []; 239 240 238 } else { 241 239 // We need to find all descendant elements 242 for ( var i = 0 , rl = ret.length; i < rl; i++ ) {240 for ( var i = 0; ret[i]; i++ ) { 243 241 // Grab the tag name being searched for 244 242 var tag = m[1] != "" || m[0] == "" ? "*" : m[2]; … … 253 251 // It's faster to filter by class and be done with it 254 252 if ( m[1] == "." ) 255 r = jQuery.grep( r, function(e) { 256 return jQuery.className.has(e, m[2]); 257 }); 253 r = jQuery.classFilter( r, m[2] ); 258 254 259 255 // Same with ID filtering 260 256 if ( m[1] == "#" ) { 261 // Remember, then wipe out, the result set 262 var tmp = r; 263 r = []; 264 265 // Then try to find the element with the ID 266 jQuery.each( tmp, function(){ 267 if ( this.getAttribute("id") == m[2] ) { 268 r = [ this ]; 269 return false; 257 var tmp = []; 258 259 // Try to find the element with the ID 260 for ( var i = 0; r[i]; i++ ) 261 if ( r[i].getAttribute("id") == m[2] ) { 262 tmp = [ r[i] ]; 263 break; 270 264 } 271 }); 265 266 r = tmp; 272 267 } 273 268 … … 304 299 }, 305 300 301 classFilter: function(r,m,not){ 302 m = " " + m + " "; 303 var tmp = []; 304 for ( var i = 0; r[i]; i++ ) { 305 var pass = (" " + r[i].className + " ").indexOf( m ) >= 0; 306 if ( !not && pass || not && !pass ) 307 tmp.push( r[i] ); 308 } 309 return tmp; 310 }, 311 306 312 filter: function(t,r,not) { 307 313 var last; … … 313 319 var p = jQuery.parse, m; 314 320 315 jQuery.each( p, function(i,re){ 316 317 // Look for, and replace, string-like sequences 318 // and finally build a regexp out of it 319 m = re.exec( t ); 321 for ( var i = 0; p[i]; i++ ) { 322 m = p[i].exec( t ); 320 323 321 324 if ( m ) { … … 329 332 m[2] = m[2].replace(/\\/g, ""); 330 333 331 return false;334 break; 332 335 } 333 } );336 } 334 337 335 338 if ( !m ) 336 continue;339 break; 337 340 338 341 // :not() is a special case that can be optimized by … … 340 343 if ( m[1] == ":" && m[2] == "not" ) 341 344 r = jQuery.filter(m[3], r, true).r; 345 346 // We can get a big speed boost by filtering by class here 347 else if ( m[1] == "." ) 348 r = jQuery.classFilter(r, m[2], not); 342 349 343 350 // Otherwise, find the expression to execute
