diff --git a/packages/alpinejs/src/directives/x-teleport.js b/packages/alpinejs/src/directives/x-teleport.js index 274b8eec5..48dd16940 100644 --- a/packages/alpinejs/src/directives/x-teleport.js +++ b/packages/alpinejs/src/directives/x-teleport.js @@ -51,8 +51,6 @@ directive('teleport', (el, { modifiers, expression }, { cleanup }) => { skipDuringClone(() => { initTree(clone) - - clone._x_ignore = true })() }) diff --git a/tests/cypress/integration/directives/x-teleport.spec.js b/tests/cypress/integration/directives/x-teleport.spec.js index e971450fb..c4a714ab2 100644 --- a/tests/cypress/integration/directives/x-teleport.spec.js +++ b/tests/cypress/integration/directives/x-teleport.spec.js @@ -204,3 +204,26 @@ test('$id honors x-id outside teleport', get('#b h1').should(haveText('foo-1')) }, ) + +test('conditionally added elements get initialised inside teleport', + [html` +
+ + + +
+ +
+ `], + ({ get }) => { + get('#b p').should('not.exist') + get('button').click() + get('#b p').should('exist').and('have.text', 'Teleport content initialised') + }, +)