This repository was archived by the owner on Apr 12, 2024. It is now read-only.
File tree 2 files changed +21
-5
lines changed
2 files changed +21
-5
lines changed Original file line number Diff line number Diff line change @@ -370,17 +370,31 @@ function jqLiteAddClass(element, cssClasses) {
370
370
}
371
371
}
372
372
373
+
373
374
function jqLiteAddNodes ( root , elements ) {
375
+ // THIS CODE IS VERY HOT. Don't make changes without benchmarking.
376
+
374
377
if ( elements ) {
375
- elements = ( ! elements . nodeName && isDefined ( elements . length ) && ! isWindow ( elements ) )
376
- ? elements
377
- : [ elements ] ;
378
- for ( var i = 0 ; i < elements . length ; i ++ ) {
379
- root . push ( elements [ i ] ) ;
378
+
379
+ // if a Node (the most common case)
380
+ if ( elements . nodeType ) {
381
+ root [ root . length ++ ] = elements ;
382
+ } else {
383
+ var length = elements . length ;
384
+
385
+ // if an Array or NodeList and not a Window
386
+ if ( typeof length === 'number' && elements . window !== elements ) {
387
+ if ( length ) {
388
+ push . apply ( root , elements ) ;
389
+ }
390
+ } else {
391
+ root [ root . length ++ ] = elements ;
392
+ }
380
393
}
381
394
}
382
395
}
383
396
397
+
384
398
function jqLiteController ( element , name ) {
385
399
return jqLiteInheritedData ( element , '$' + ( name || 'ngController' ) + 'Controller' ) ;
386
400
}
Original file line number Diff line number Diff line change @@ -963,6 +963,8 @@ describe('jqLite', function() {
963
963
} ,
964
964
detachEvent : noop
965
965
} ;
966
+ window . window = window ;
967
+
966
968
var log ;
967
969
var jWindow = jqLite ( window ) . on ( 'hashchange' , function ( ) {
968
970
log = 'works!' ;
You can’t perform that action at this time.
0 commit comments