nested components skip intro on initial render - fixes #1460

pull/1477/head
Rich Harris 7 years ago
parent 017e6cb46f
commit b45b2415f2

@ -182,7 +182,7 @@ export default function dom(
})} })}
${compiler.bindingGroups.length && ${compiler.bindingGroups.length &&
`this._bindingGroups = [${Array(compiler.bindingGroups.length).fill('[]').join(', ')}];`} `this._bindingGroups = [${Array(compiler.bindingGroups.length).fill('[]').join(', ')}];`}
this._intro = ${compiler.options.skipIntroByDefault ? 'options.intro' : 'true'}; this._intro = ${compiler.options.skipIntroByDefault ? '!!options.intro' : 'true'};
${templateProperties.onstate && `this._handlers.state = [%onstate];`} ${templateProperties.onstate && `this._handlers.state = [%onstate];`}
${templateProperties.onupdate && `this._handlers.update = [%onupdate];`} ${templateProperties.onupdate && `this._handlers.update = [%onupdate];`}

@ -700,7 +700,7 @@ export default class Element extends Node {
const fn = `%transitions-${intro.name}`; const fn = `%transitions-${intro.name}`;
block.builders.intro.addConditional(`#component._intro`, deindent` block.builders.intro.addConditional(`#component.root._intro`, deindent`
if (${name}) ${name}.invalidate(); if (${name}) ${name}.invalidate();
#component.root._aftercreate.push(() => { #component.root._aftercreate.push(() => {
@ -735,7 +735,7 @@ export default class Element extends Node {
`); `);
} }
block.builders.intro.addConditional(`#component._intro`, deindent` block.builders.intro.addConditional(`#component.root._intro`, deindent`
#component.root._aftercreate.push(() => { #component.root._aftercreate.push(() => {
${introName} = @wrapTransition(#component, ${this.var}, ${fn}, ${snippet}, true); ${introName} = @wrapTransition(#component, ${this.var}, ${fn}, ${snippet}, true);
${introName}.run(1); ${introName}.run(1);

@ -0,0 +1,16 @@
<div transition:foo></div>
<script>
export default {
transitions: {
foo(node, params) {
return {
duration: 100,
tick: t => {
node.foo = t;
}
};
}
}
};
</script>

@ -0,0 +1,11 @@
export default {
skipIntroByDefault: true,
test(assert, component, target, window, raf) {
const div = target.querySelector('div');
assert.equal(div.foo, undefined);
raf.tick(50);
assert.equal(div.foo, undefined);
},
};

@ -0,0 +1,9 @@
<Widget/>
<script>
export default {
components: {
Widget: './Widget.html'
}
};
</script>
Loading…
Cancel
Save