fix component hydration

pull/649/head
Rich Harris 8 years ago
parent 0bbd917442
commit dc29b2d466

@ -113,7 +113,6 @@ export default function visitComponent(
}
const componentInitProperties = [
`target: ${!isTopLevel ? state.parentNode : 'null'}`,
`_root: ${block.component}._root`,
];
@ -123,7 +122,7 @@ export default function visitComponent(
const childBlock = node._block;
node.children.forEach(child => {
node.children.forEach((child: Node) => {
visit(generator, childBlock, childState, child);
});
@ -224,8 +223,12 @@ export default function visitComponent(
block.builders.init.addBlock(local.create);
const targetNode = state.parentNode || block.target;
const anchorNode = state.parentNode ? 'null' : 'anchor';
block.builders.create.addLine(`${name}._fragment.create();`);
block.builders.claim.addLine(`${name}._fragment.claim( ${state.parentNodes} );`);
block.builders.mount.addLine(`${name}._fragment.mount( ${targetNode}, ${anchorNode} );` );
if (!local.update.isEmpty()) block.builders.update.addBlock(local.update);
}

@ -83,7 +83,6 @@ export function claimElement (nodes, name, attributes) {
}
}
console.trace('creating', name);
return createElement(name);
}

@ -0,0 +1,21 @@
export default {
snapshot(target) {
const div = target.querySelector('div');
const p = target.querySelector('p');
return {
div,
p,
text: p.childNodes[0]
};
},
test(assert, target, snapshot) {
const div = target.querySelector('div');
const p = target.querySelector('p');
assert.equal(div, snapshot.div);
assert.equal(p, snapshot.p);
assert.equal(p.childNodes[0], snapshot.text);
}
};

@ -0,0 +1,13 @@
<div>
<Nested/>
</div>
<script>
import Nested from './Nested.html';
export default {
components: {
Nested
}
};
</script>
Loading…
Cancel
Save