This repository was archived by the owner on Mar 13, 2018. It is now read-only.
File tree 2 files changed +25
-1
lines changed
2 files changed +25
-1
lines changed Original file line number Diff line number Diff line change 401
401
} else {
402
402
if ( ! previousNode )
403
403
this . firstChild_ = nodes [ 0 ] ;
404
- if ( ! refWrapper )
404
+ if ( ! refWrapper ) {
405
405
this . lastChild_ = nodes [ nodes . length - 1 ] ;
406
+ if ( this . firstChild_ === undefined )
407
+ this . firstChild_ = this . firstChild ;
408
+ }
406
409
407
410
var parentNode = refNode ? refNode . parentNode : this . impl ;
408
411
Original file line number Diff line number Diff line change @@ -392,4 +392,25 @@ suite('Node', function() {
392
392
assert . equal ( sr . firstChild . nextSibling . textContent , 'quux' ) ;
393
393
} ) ;
394
394
395
+ test ( 'appendChild last and first' , function ( ) {
396
+ var a = document . createElement ( 'a' ) ;
397
+ a . innerHTML = '<b></b>' ;
398
+ var b = a . firstChild ;
399
+ var sr = a . createShadowRoot ( ) ;
400
+
401
+ var c = document . createElement ( 'c' ) ;
402
+ c . innerHTML = '<d></d>' ;
403
+ var d = c . firstChild ;
404
+ c . appendChild ( b ) ;
405
+
406
+ var cs = c . childNodes ;
407
+ assert . equal ( cs . length , 2 ) ;
408
+ assert . equal ( cs [ 0 ] , d ) ;
409
+ assert . equal ( cs [ 1 ] , b ) ;
410
+
411
+ c . removeChild ( b ) ;
412
+ cs = c . childNodes ;
413
+ assert . equal ( cs . length , 1 ) ;
414
+ assert . equal ( cs [ 0 ] , d ) ;
415
+ } ) ;
395
416
} ) ;
You can’t perform that action at this time.
0 commit comments