@@ -9,7 +9,7 @@ class tApp {
99 static currentHash = "/" ;
1010 static debugComponentTiming ;
1111 static get version ( ) {
12- return "v0.10.6 " ;
12+ return "v0.10.7 " ;
1313 }
1414 static configure ( params ) {
1515 if ( params == null ) {
@@ -410,6 +410,17 @@ class tApp {
410410 }
411411 return tApp . eval ( tApp . optionsToEval ( data ) + `let _____tApp_____result = (function() {return eval("${ code . replaceAll ( "\"" , "\\\"" ) } ")})();${ tApp . restoreOptions ( data ) } [_____tApp_____result, _____tApp_____returnOptions]` ) ;
412412 }
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+ }
413424 static getComponent ( id ) {
414425 return tApp . components [ id ] ;
415426 }
@@ -548,20 +559,28 @@ class tApp {
548559 } else {
549560 let nextNotNull ;
550561 for ( let j = i ; nextNotNull == null && j < beforeChildren . length ; j ++ ) {
551- if ( beforeChildren [ j ] != null ) {
562+ if ( beforeChildren [ j ] != null && beforeChildren [ j ] . nodeName != "#text" ) {
552563 nextNotNull = beforeChildren [ j ] ;
553564 }
554565 }
555566 if ( nextNotNull == null ) {
556567 let prevNotNull ;
557568 for ( let j = i ; prevNotNull == null && j < beforeChildren . length ; j -- ) {
558- if ( beforeChildren [ j ] != null ) {
569+ if ( beforeChildren [ j ] != null && beforeChildren [ j ] . nodeName != "#text" ) {
559570 prevNotNull = beforeChildren [ j ] ;
560571 }
561572 }
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+ }
563578 } 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+ }
565584 }
566585 }
567586 } else if ( afterChildren [ i ] == null ) {
@@ -633,7 +652,7 @@ class tApp {
633652 state : parentState ,
634653 id : parentId
635654 } ,
636- _this : "tApp.getComponent (this.getAttribute('tapp-component') )" ,
655+ _this : "tApp.getComponentFromDOM (this)" ,
637656 _parent : `tApp.getComponent("${ parentId } ")`
638657 } , component . id ) ;
639658 } else {
0 commit comments