Skip to content

Commit 2025817

Browse files
authored
revert (#4084)
1 parent 28d1206 commit 2025817

File tree

3 files changed

+2
-43
lines changed

3 files changed

+2
-43
lines changed

packages/alpinejs/src/lifecycle.js

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -81,23 +81,13 @@ export function interceptInit(callback) { initInterceptors.push(callback) }
8181
export function initTree(el, walker = walk, intercept = () => {}) {
8282
deferHandlingDirectives(() => {
8383
walker(el, (el, skip) => {
84-
if (el._x_inited) {
85-
if (el._x_ignore) skip()
86-
87-
return
88-
}
89-
9084
intercept(el, skip)
9185

9286
initInterceptors.forEach(i => i(el, skip))
9387

9488
directives(el, el.attributes).forEach(handle => handle())
9589

96-
if (el._x_ignore) {
97-
skip()
98-
} else {
99-
el._x_inited = true
100-
}
90+
el._x_ignore && skip()
10191
})
10292
})
10393
}
@@ -106,7 +96,5 @@ export function destroyTree(root, walker = walk) {
10696
walker(root, el => {
10797
cleanupAttributes(el)
10898
cleanupElement(el)
109-
110-
delete el._x_inited
11199
})
112100
}

packages/alpinejs/src/mutation.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ function onMutate(mutations) {
196196
for (let node of addedNodes) {
197197
// If the node was eventually removed as part of one of his
198198
// parent mutations, skip it
199+
if (removedNodes.has(node)) continue
199200
if (! node.isConnected) continue
200201

201202
delete node._x_ignoreSelf

tests/cypress/integration/mutation.spec.js

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -136,36 +136,6 @@ test('can pause and queue mutations for later resuming/flushing',
136136
}
137137
)
138138

139-
test('add and move element are been initialized',
140-
html`
141-
<div x-data="{
142-
foo: 0,
143-
bar: 0,
144-
test() {
145-
container = document.createElement('div')
146-
this.$root.appendChild(container)
147-
alpineElement = document.createElement('span')
148-
alpineElement.setAttribute('x-data', '{init() {this.bar++}}')
149-
alpineElement.setAttribute('x-init', 'foo++')
150-
container.appendChild(alpineElement)
151-
container.removeChild(alpineElement)
152-
container.appendChild(alpineElement)
153-
}
154-
}">
155-
<span id="one" x-text="foo"></span>
156-
<span id="two" x-text="bar"></span>
157-
<button @click="test">Test</button>
158-
</div>
159-
`,
160-
({ get }) => {
161-
get('span#one').should(haveText('0'))
162-
get('span#two').should(haveText('0'))
163-
get('button').click()
164-
get('span#one').should(haveText('1'))
165-
get('span#two').should(haveText('1'))
166-
}
167-
)
168-
169139
test('does not initialise components twice when contained in multiple mutations',
170140
html`
171141
<div x-data="{

0 commit comments

Comments
 (0)