@@ -342,7 +342,10 @@ class Slim extends HTMLElement {
342
342
}
343
343
344
344
createdCallback ( ) {
345
+ // __createdCallbackRunOnce is required for babel louzy transpiling
345
346
if ( this . isVirtual ) return ;
347
+ if ( this . __createdCallbackRunOnce ) return ;
348
+ this . __createdCallbackRunOnce = true ;
346
349
this . initialize ( ) ;
347
350
this . onBeforeCreated ( ) ;
348
351
this . _captureBindings ( ) ;
@@ -435,6 +438,7 @@ class Slim extends HTMLElement {
435
438
436
439
437
440
_executeBindings ( prop ) {
441
+ if ( ! this . _bindings ) return ;
438
442
// reset bound texts
439
443
this . _boundChildren . forEach ( child => {
440
444
// this._boundChildren.forEach( child => {
@@ -466,14 +470,16 @@ class Slim extends HTMLElement {
466
470
let $tpl = this . alternateTemplate || this . template ;
467
471
if ( ! $tpl ) {
468
472
while ( this . children . length ) {
469
- this . _virtualDOM . appendChild ( this . children [ 0 ] )
473
+ // TODO: find why this line is needed for babel!!!
474
+ self . _virtualDOM = this . _virtualDOM || document . createElement ( 'slim-root' )
475
+ self . _virtualDOM . appendChild ( this . children [ 0 ] )
470
476
}
471
477
} else if ( typeof ( $tpl ) === 'string' ) {
472
478
this . _virtualDOM . innerHTML = $tpl ;
473
479
let virtualContent = this . _virtualDOM . querySelector ( 'slim-content' ) ;
474
480
if ( virtualContent ) {
475
- while ( this . children . length ) {
476
- this . children [ 0 ] . _boundParent = this . children [ 0 ] . _boundParent || this ;
481
+ while ( self . children . length ) {
482
+ self . children [ 0 ] . _boundParent = this . children [ 0 ] . _boundParent || this ;
477
483
virtualContent . appendChild ( this . children [ 0 ] )
478
484
}
479
485
}
@@ -483,7 +489,9 @@ class Slim extends HTMLElement {
483
489
for ( let child of allChildren ) {
484
490
child . _sourceOuterHTML = child . outerHTML ;
485
491
child . _boundParent = child . _boundParent || this ;
486
- this . _boundChildren . push ( child ) ;
492
+ self . _boundChildren = this . _boundChildren || [ ] ;
493
+ self . _boundChildren . push ( child ) ;
494
+ self . _boundChildren . push ( child ) ;
487
495
if ( child . getAttribute ( 'slim-id' ) ) {
488
496
child . _boundParent [ Slim . __dashToCamel ( child . getAttribute ( 'slim-id' ) ) ] = child
489
497
}
0 commit comments