Skip to content

Commit 9b96a2c

Browse files
Fix test: only rerender while fragment is detached, not after appending to DOM
Agent-Logs-Url: https://github.com/emberjs/ember.js/sessions/509016a2-4d3c-4fa7-9143-d386e636ec22 Co-authored-by: NullVoxPopuli <199018+NullVoxPopuli@users.noreply.github.com>
1 parent 8eb9b7d commit 9b96a2c

File tree

1 file changed

+16
-13
lines changed

1 file changed

+16
-13
lines changed

packages/@glimmer-workspace/integration-tests/lib/suites/in-element-document-fragment.ts

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ export class InElementDocumentFragmentSuite extends RenderTest {
133133
}
134134

135135
@test
136-
'After fragment is attached to DOM, text updates and new conditional elements appear in the container'(
136+
'Rerenders in a detached DocumentFragment, then content is visible after attaching to DOM'(
137137
assert: typeof QUnit.assert
138138
) {
139139
const fragment = document.createDocumentFragment();
@@ -160,24 +160,27 @@ export class InElementDocumentFragmentSuite extends RenderTest {
160160

161161
assert.verifySteps(['initial'], 'initial render fires step from inside fragment');
162162

163-
// Move fragment's children (including Glimmer's comment bounds) into the container
164-
container.appendChild(fragment);
165-
166-
// Text-node update: Glimmer holds a direct reference to the text node, so the
167-
// update is visible in the container even though the fragment is now empty.
163+
// Rerender while still detached: text update
168164
this.rerender({ message: 'updated' });
169-
assert.verifySteps(
170-
['updated'],
171-
'text update fires step even after fragment was attached to the DOM'
172-
);
165+
assert.verifySteps(['updated'], 'text update fires step while fragment is still detached');
173166

174-
// New-element update: Glimmer inserts the span relative to the comment bounds,
175-
// which also moved to the container, so the new element appears in the container.
167+
// Rerender while still detached: conditional element appears
176168
this.rerender({ show: true });
177169
assert.verifySteps(
178170
['extra rendered'],
179-
'conditional element step fires in the container after fragment was attached to the DOM'
171+
'conditional element step fires while fragment is still detached'
180172
);
173+
174+
// Move the fragment's children into the container; after this the fragment is empty
175+
// but the rendered nodes (including the reactive text and the conditional span) are
176+
// now live children of `container`.
177+
container.appendChild(fragment);
178+
assert.strictEqual(fragment.childNodes.length, 0, 'fragment is empty after append');
179+
180+
const p = container.querySelector('#msg');
181+
const span = container.querySelector('#extra');
182+
assert.ok(p, 'paragraph is present in container');
183+
assert.ok(span, 'conditional span is present in container');
181184
}
182185

183186
@test

0 commit comments

Comments
 (0)