Skip to content

Commit

Permalink
Merge pull request #1477 from sveltejs/gh-1460
Browse files Browse the repository at this point in the history
nested components skip intro on initial render
  • Loading branch information
Rich-Harris authored May 17, 2018
2 parents cffbd27 + b45b241 commit 3f6d0e7
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/compile/dom/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ export default function dom(
})}
${compiler.bindingGroups.length &&
`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.onupdate && `this._handlers.update = [%onupdate];`}
Expand Down
4 changes: 2 additions & 2 deletions src/compile/nodes/Element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -700,7 +700,7 @@ export default class Element extends Node {

const fn = `%transitions-${intro.name}`;

block.builders.intro.addConditional(`#component._intro`, deindent`
block.builders.intro.addConditional(`#component.root._intro`, deindent`
if (${name}) ${name}.invalidate();
#component.root._aftercreate.push(() => {
Expand Down Expand Up @@ -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(() => {
${introName} = @wrapTransition(#component, ${this.var}, ${fn}, ${snippet}, true);
${introName}.run(1);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<div transition:foo></div>

<script>
export default {
transitions: {
foo(node, params) {
return {
duration: 100,
tick: t => {
node.foo = t;
}
};
}
}
};
</script>
Original file line number Diff line number Diff line change
@@ -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);
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<Widget/>

<script>
export default {
components: {
Widget: './Widget.html'
}
};
</script>

0 comments on commit 3f6d0e7

Please sign in to comment.