fix: better handling of empty text node hydration

pull/10545/head
Dominic Gannaway 3 years ago
parent 56b71665b5
commit fa3d118550

@ -1,12 +1,15 @@
import { test } from '../../test';
export default test({
html: `<button></button>`,
html: `<button type="button">Update Text</button><div></div>`,
async test({ assert, target }) {
const btn = target.querySelector('button');
await btn?.click();
assert.htmlEqual(target.innerHTML, `<button>foo</button>`);
assert.htmlEqual(
target.innerHTML,
`<button type="button">Update Text</button><div>updated</div>`
);
}
});

@ -1,5 +1,11 @@
<script>
let foo = $state();
let text = $state('');
function update_text() {
text = 'updated';
}
</script>
<button on:click={() => foo = 'foo'}>{foo}</button>
<button type="button" on:click={update_text}>Update Text</button>
<div>{text}</div>

@ -1,15 +1,12 @@
import { test } from '../../test';
export default test({
html: `<button type="button">Update Text</button><div></div>`,
html: `<button></button>`,
async test({ assert, target }) {
const btn = target.querySelector('button');
await btn?.click();
assert.htmlEqual(
target.innerHTML,
`<button type="button">Update Text</button><div>updated</div>`
);
assert.htmlEqual(target.innerHTML, `<button>foo</button>`);
}
});

@ -1,11 +1,5 @@
<script>
let text = $state('');
function update_text() {
text = 'updated';
}
let foo = $state();
</script>
<button type="button" on:click={update_text}>Update Text</button>
<div>{text}</div>
<button on:click={() => foo = 'foo'}>{foo}</button>

Loading…
Cancel
Save