fix hydration

pull/3539/head
Richard Harris 6 years ago
parent 7348390957
commit e3c98cf279

@ -59,6 +59,6 @@ export default class Renderer {
this.block.assign_variable_names(); this.block.assign_variable_names();
this.fragment.render(this.block, null, x`nodes` as Identifier); this.fragment.render(this.block, null, x`#nodes` as Identifier);
} }
} }

@ -234,7 +234,7 @@ export default class AwaitBlockWrapper extends Wrapper {
`); `);
[this.pending, this.then, this.catch].forEach(branch => { [this.pending, this.then, this.catch].forEach(branch => {
branch.fragment.render(branch.block, null, x`nodes` as Identifier); branch.fragment.render(branch.block, null, x`#nodes` as Identifier);
}); });
} }
} }

@ -300,10 +300,10 @@ export default class EachBlockWrapper extends Wrapper {
`); `);
} }
this.fragment.render(this.block, null, x`nodes` as Identifier); this.fragment.render(this.block, null, x`#nodes` as Identifier);
if (this.else) { if (this.else) {
this.else.fragment.render(this.else.block, null, x`nodes` as Identifier); this.else.fragment.render(this.else.block, null, x`#nodes` as Identifier);
} }
} }

@ -264,7 +264,7 @@ export default class ElementWrapper extends Wrapper {
if (parent_nodes) { if (parent_nodes) {
block.chunks.claim.push(b` block.chunks.claim.push(b`
${node} = ${this.get_claim_statement(parent_nodes)}; ${node} = ${this.get_claim_statement(parent_nodes)};
var ${nodes} = @children(${this.node.name === 'template' ? `${node}.content` : node}); var ${nodes} = @children(${this.node.name === 'template' ? x`${node}.content` : node});
`); `);
} else { } else {
block.chunks.claim.push( block.chunks.claim.push(
@ -321,7 +321,7 @@ export default class ElementWrapper extends Wrapper {
this.fragment.nodes.forEach((child: Wrapper) => { this.fragment.nodes.forEach((child: Wrapper) => {
child.render( child.render(
block, block,
this.node.name === 'template' ? `${node}.content` : node, this.node.name === 'template' ? x`${node}.content` : node,
nodes nodes
); );
}); });
@ -387,9 +387,9 @@ export default class ElementWrapper extends Wrapper {
? this.node.name ? this.node.name
: this.node.name.toUpperCase(); : this.node.name.toUpperCase();
return x`@claim_element(${nodes}, "${name}", ${attributes const svg = this.node.namespace === namespaces.svg ? 1 : null;
? x`{ ${attributes} }`
: x`{}`}, ${this.node.namespace === namespaces.svg ? true : false})`; return x`@claim_element(${nodes}, "${name}", { ${attributes} }, ${svg})`;
} }
add_bindings(block: Block) { add_bindings(block: Block) {

@ -32,6 +32,6 @@ export default class HeadWrapper extends Wrapper {
} }
render(block: Block, _parent_node: Identifier, _parent_nodes: Identifier) { render(block: Block, _parent_node: Identifier, _parent_nodes: Identifier) {
this.fragment.render(block, x`@_document.head` as unknown as Identifier, x`nodes` as unknown as Identifier); this.fragment.render(block, x`@_document.head` as unknown as Identifier, x`#nodes` as unknown as Identifier);
} }
} }

@ -235,7 +235,7 @@ export default class IfBlockWrapper extends Wrapper {
} }
this.branches.forEach(branch => { this.branches.forEach(branch => {
branch.fragment.render(branch.block, null, x`nodes` as unknown as Identifier); branch.fragment.render(branch.block, null, x`#nodes` as unknown as Identifier);
}); });
} }

@ -157,7 +157,7 @@ export default class InlineComponentWrapper extends Wrapper {
const default_slot = this.slots.get('default'); const default_slot = this.slots.get('default');
this.fragment.nodes.forEach((child) => { this.fragment.nodes.forEach((child) => {
child.render(default_slot.block, null, x`nodes` as unknown as Identifier); child.render(default_slot.block, null, x`#nodes` as unknown as Identifier);
}); });
} }

@ -216,7 +216,7 @@ describe.only("runtime", () => {
fs.readdirSync("test/runtime/samples").forEach(dir => { fs.readdirSync("test/runtime/samples").forEach(dir => {
runTest(dir, false); runTest(dir, false);
// runTest(dir, true); runTest(dir, true);
}); });
async function create_component(src = '<div></div>') { async function create_component(src = '<div></div>') {

Loading…
Cancel
Save