@@ -9,7 +9,7 @@ class tApp {
9
9
static currentHash = "/" ;
10
10
static debugComponentTiming ;
11
11
static get version ( ) {
12
- return "v0.10.6 " ;
12
+ return "v0.10.7 " ;
13
13
}
14
14
static configure ( params ) {
15
15
if ( params == null ) {
@@ -410,6 +410,17 @@ class tApp {
410
410
}
411
411
return tApp . eval ( tApp . optionsToEval ( data ) + `let _____tApp_____result = (function() {return eval("${ code . replaceAll ( "\"" , "\\\"" ) } ")})();${ tApp . restoreOptions ( data ) } [_____tApp_____result, _____tApp_____returnOptions]` ) ;
412
412
}
413
+ static getComponentFromDOM ( domElement ) {
414
+ let component = null ;
415
+ while ( ( domElement != null && domElement . nodeName . substring ( 0 , 1 ) != "#" ) && domElement . getAttribute ( 'tapp-component' ) == null ) {
416
+ domElement = domElement . parentNode ;
417
+ }
418
+ if ( domElement == null || domElement . nodeName . substring ( 0 , 1 ) == "#" ) {
419
+ return null ;
420
+ } else {
421
+ return tApp . getComponent ( domElement . getAttribute ( 'tapp-component' ) ) ;
422
+ }
423
+ }
413
424
static getComponent ( id ) {
414
425
return tApp . components [ id ] ;
415
426
}
@@ -548,20 +559,28 @@ class tApp {
548
559
} else {
549
560
let nextNotNull ;
550
561
for ( let j = i ; nextNotNull == null && j < beforeChildren . length ; j ++ ) {
551
- if ( beforeChildren [ j ] != null ) {
562
+ if ( beforeChildren [ j ] != null && beforeChildren [ j ] . nodeName != "#text" ) {
552
563
nextNotNull = beforeChildren [ j ] ;
553
564
}
554
565
}
555
566
if ( nextNotNull == null ) {
556
567
let prevNotNull ;
557
568
for ( let j = i ; prevNotNull == null && j < beforeChildren . length ; j -- ) {
558
- if ( beforeChildren [ j ] != null ) {
569
+ if ( beforeChildren [ j ] != null && beforeChildren [ j ] . nodeName != "#text" ) {
559
570
prevNotNull = beforeChildren [ j ] ;
560
571
}
561
572
}
562
- prevNotNull . insertAdjacentElement ( "afterend" , afterChildren [ i ] ) ;
573
+ if ( afterChildren [ i ] . nodeName == "#text" ) {
574
+ prevNotNull . insertAdjacentText ( "afterend" , afterChildren [ i ] . nodeValue ) ;
575
+ } else {
576
+ prevNotNull . insertAdjacentElement ( "afterend" , afterChildren [ i ] ) ;
577
+ }
563
578
} else {
564
- nextNotNull . insertAdjacentElement ( "beforebegin" , afterChildren [ i ] ) ;
579
+ if ( afterChildren [ i ] . nodeName == "#text" ) {
580
+ nextNotNull . insertAdjacentText ( "beforebegin" , afterChildren [ i ] . nodeValue ) ;
581
+ } else {
582
+ nextNotNull . insertAdjacentElement ( "beforebegin" , afterChildren [ i ] ) ;
583
+ }
565
584
}
566
585
}
567
586
} else if ( afterChildren [ i ] == null ) {
@@ -633,7 +652,7 @@ class tApp {
633
652
state : parentState ,
634
653
id : parentId
635
654
} ,
636
- _this : "tApp.getComponent (this.getAttribute('tapp-component') )" ,
655
+ _this : "tApp.getComponentFromDOM (this)" ,
637
656
_parent : `tApp.getComponent("${ parentId } ")`
638
657
} , component . id ) ;
639
658
} else {
0 commit comments