Merge pull request #1137 from sveltejs/gh-1135

Fix order of `oncreate` in sibling components
pull/1142/head
Rich Harris 7 years ago committed by GitHub
commit 3cd9779b37
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -245,20 +245,20 @@ export default function dom(
${(templateProperties.oncreate || generator.hasComponents || generator.hasComplexBindings || generator.hasIntroTransitions) && deindent` ${(templateProperties.oncreate || generator.hasComponents || generator.hasComplexBindings || generator.hasIntroTransitions) && deindent`
if (!options.root) { if (!options.root) {
this._oncreate = [${templateProperties.oncreate && `_oncreate`}]; this._oncreate = [];
${(generator.hasComponents || generator.hasComplexBindings) && `this._beforecreate = [];`} ${(generator.hasComponents || generator.hasComplexBindings) && `this._beforecreate = [];`}
${(generator.hasComponents || generator.hasIntroTransitions) && `this._aftercreate = [];`} ${(generator.hasComponents || generator.hasIntroTransitions) && `this._aftercreate = [];`}
} ${templateProperties.oncreate && deindent`
else {
this.root._oncreate.push(_oncreate);
} }
`} `}
`}
${generator.slots.size && `this.slots = {};`} ${generator.slots.size && `this.slots = {};`}
this._fragment = @create_main_fragment(this._state, this); this._fragment = @create_main_fragment(this._state, this);
${(templateProperties.oncreate) && deindent`
this.root._oncreate.push(_oncreate);
`}
${generator.customElement ? deindent` ${generator.customElement ? deindent`
this._fragment.c(); this._fragment.c();
this._fragment.${block.hasIntroMethod ? 'i' : 'm'}(this.shadowRoot, null); this._fragment.${block.hasIntroMethod ? 'i' : 'm'}(this.shadowRoot, null);

@ -177,7 +177,7 @@ export function setDev(newState) {
} }
export function callAll(fns) { export function callAll(fns) {
while (fns && fns.length) fns.pop()(); while (fns && fns.length) fns.shift()();
} }
export function _mount(target, anchor) { export function _mount(target, anchor) {

@ -167,7 +167,7 @@ function _set(newState) {
} }
function callAll(fns) { function callAll(fns) {
while (fns && fns.length) fns.pop()(); while (fns && fns.length) fns.shift()();
} }
function _mount(target, anchor) { function _mount(target, anchor) {

@ -143,7 +143,7 @@ function _set(newState) {
} }
function callAll(fns) { function callAll(fns) {
while (fns && fns.length) fns.pop()(); while (fns && fns.length) fns.shift()();
} }
function _mount(target, anchor) { function _mount(target, anchor) {

@ -143,7 +143,7 @@ function _set(newState) {
} }
function callAll(fns) { function callAll(fns) {
while (fns && fns.length) fns.pop()(); while (fns && fns.length) fns.shift()();
} }
function _mount(target, anchor) { function _mount(target, anchor) {

@ -163,7 +163,7 @@ function _set(newState) {
} }
function callAll(fns) { function callAll(fns) {
while (fns && fns.length) fns.pop()(); while (fns && fns.length) fns.shift()();
} }
function _mount(target, anchor) { function _mount(target, anchor) {

@ -155,7 +155,7 @@ function _set(newState) {
} }
function callAll(fns) { function callAll(fns) {
while (fns && fns.length) fns.pop()(); while (fns && fns.length) fns.shift()();
} }
function _mount(target, anchor) { function _mount(target, anchor) {

@ -143,7 +143,7 @@ function _set(newState) {
} }
function callAll(fns) { function callAll(fns) {
while (fns && fns.length) fns.pop()(); while (fns && fns.length) fns.shift()();
} }
function _mount(target, anchor) { function _mount(target, anchor) {
@ -201,13 +201,13 @@ function SvelteComponent(options) {
var _oncreate = oncreate.bind(this); var _oncreate = oncreate.bind(this);
if (!options.root) { if (!options.root) {
this._oncreate = [_oncreate]; this._oncreate = [];
} else {
this.root._oncreate.push(_oncreate);
} }
this._fragment = create_main_fragment(this._state, this); this._fragment = create_main_fragment(this._state, this);
this.root._oncreate.push(_oncreate);
if (options.target) { if (options.target) {
this._fragment.c(); this._fragment.c();
this._fragment.m(options.target, options.anchor || null); this._fragment.m(options.target, options.anchor || null);

@ -33,13 +33,13 @@ function SvelteComponent(options) {
var _oncreate = oncreate.bind(this); var _oncreate = oncreate.bind(this);
if (!options.root) { if (!options.root) {
this._oncreate = [_oncreate]; this._oncreate = [];
} else {
this.root._oncreate.push(_oncreate);
} }
this._fragment = create_main_fragment(this._state, this); this._fragment = create_main_fragment(this._state, this);
this.root._oncreate.push(_oncreate);
if (options.target) { if (options.target) {
this._fragment.c(); this._fragment.c();
this._fragment.m(options.target, options.anchor || null); this._fragment.m(options.target, options.anchor || null);

@ -159,7 +159,7 @@ function _set(newState) {
} }
function callAll(fns) { function callAll(fns) {
while (fns && fns.length) fns.pop()(); while (fns && fns.length) fns.shift()();
} }
function _mount(target, anchor) { function _mount(target, anchor) {

@ -163,7 +163,7 @@ function _set(newState) {
} }
function callAll(fns) { function callAll(fns) {
while (fns && fns.length) fns.pop()(); while (fns && fns.length) fns.shift()();
} }
function _mount(target, anchor) { function _mount(target, anchor) {

@ -163,7 +163,7 @@ function _set(newState) {
} }
function callAll(fns) { function callAll(fns) {
while (fns && fns.length) fns.pop()(); while (fns && fns.length) fns.shift()();
} }
function _mount(target, anchor) { function _mount(target, anchor) {

@ -175,7 +175,7 @@ function _set(newState) {
} }
function callAll(fns) { function callAll(fns) {
while (fns && fns.length) fns.pop()(); while (fns && fns.length) fns.shift()();
} }
function _mount(target, anchor) { function _mount(target, anchor) {

@ -155,7 +155,7 @@ function _set(newState) {
} }
function callAll(fns) { function callAll(fns) {
while (fns && fns.length) fns.pop()(); while (fns && fns.length) fns.shift()();
} }
function _mount(target, anchor) { function _mount(target, anchor) {

@ -155,7 +155,7 @@ function _set(newState) {
} }
function callAll(fns) { function callAll(fns) {
while (fns && fns.length) fns.pop()(); while (fns && fns.length) fns.shift()();
} }
function _mount(target, anchor) { function _mount(target, anchor) {

@ -159,7 +159,7 @@ function _set(newState) {
} }
function callAll(fns) { function callAll(fns) {
while (fns && fns.length) fns.pop()(); while (fns && fns.length) fns.shift()();
} }
function _mount(target, anchor) { function _mount(target, anchor) {

@ -159,7 +159,7 @@ function _set(newState) {
} }
function callAll(fns) { function callAll(fns) {
while (fns && fns.length) fns.pop()(); while (fns && fns.length) fns.shift()();
} }
function _mount(target, anchor) { function _mount(target, anchor) {

@ -159,7 +159,7 @@ function _set(newState) {
} }
function callAll(fns) { function callAll(fns) {
while (fns && fns.length) fns.pop()(); while (fns && fns.length) fns.shift()();
} }
function _mount(target, anchor) { function _mount(target, anchor) {

@ -159,7 +159,7 @@ function _set(newState) {
} }
function callAll(fns) { function callAll(fns) {
while (fns && fns.length) fns.pop()(); while (fns && fns.length) fns.shift()();
} }
function _mount(target, anchor) { function _mount(target, anchor) {

@ -159,7 +159,7 @@ function _set(newState) {
} }
function callAll(fns) { function callAll(fns) {
while (fns && fns.length) fns.pop()(); while (fns && fns.length) fns.shift()();
} }
function _mount(target, anchor) { function _mount(target, anchor) {

@ -159,7 +159,7 @@ function _set(newState) {
} }
function callAll(fns) { function callAll(fns) {
while (fns && fns.length) fns.pop()(); while (fns && fns.length) fns.shift()();
} }
function _mount(target, anchor) { function _mount(target, anchor) {

@ -163,7 +163,7 @@ function _set(newState) {
} }
function callAll(fns) { function callAll(fns) {
while (fns && fns.length) fns.pop()(); while (fns && fns.length) fns.shift()();
} }
function _mount(target, anchor) { function _mount(target, anchor) {

@ -161,7 +161,7 @@ function _set(newState) {
} }
function callAll(fns) { function callAll(fns) {
while (fns && fns.length) fns.pop()(); while (fns && fns.length) fns.shift()();
} }
function _mount(target, anchor) { function _mount(target, anchor) {

@ -178,7 +178,7 @@ function _set(newState) {
} }
function callAll(fns) { function callAll(fns) {
while (fns && fns.length) fns.pop()(); while (fns && fns.length) fns.shift()();
} }
function _mount(target, anchor) { function _mount(target, anchor) {

@ -171,7 +171,7 @@ function _set(newState) {
} }
function callAll(fns) { function callAll(fns) {
while (fns && fns.length) fns.pop()(); while (fns && fns.length) fns.shift()();
} }
function _mount(target, anchor) { function _mount(target, anchor) {

@ -157,7 +157,7 @@ function _set(newState) {
} }
function callAll(fns) { function callAll(fns) {
while (fns && fns.length) fns.pop()(); while (fns && fns.length) fns.shift()();
} }
function _mount(target, anchor) { function _mount(target, anchor) {

@ -143,7 +143,7 @@ function _set(newState) {
} }
function callAll(fns) { function callAll(fns) {
while (fns && fns.length) fns.pop()(); while (fns && fns.length) fns.shift()();
} }
function _mount(target, anchor) { function _mount(target, anchor) {
@ -197,13 +197,13 @@ function SvelteComponent(options) {
var _oncreate = oncreate.bind(this); var _oncreate = oncreate.bind(this);
if (!options.root) { if (!options.root) {
this._oncreate = [_oncreate]; this._oncreate = [];
} else {
this.root._oncreate.push(_oncreate);
} }
this._fragment = create_main_fragment(this._state, this); this._fragment = create_main_fragment(this._state, this);
this.root._oncreate.push(_oncreate);
if (options.target) { if (options.target) {
this._fragment.c(); this._fragment.c();
this._fragment.m(options.target, options.anchor || null); this._fragment.m(options.target, options.anchor || null);

@ -29,13 +29,13 @@ function SvelteComponent(options) {
var _oncreate = oncreate.bind(this); var _oncreate = oncreate.bind(this);
if (!options.root) { if (!options.root) {
this._oncreate = [_oncreate]; this._oncreate = [];
} else {
this.root._oncreate.push(_oncreate);
} }
this._fragment = create_main_fragment(this._state, this); this._fragment = create_main_fragment(this._state, this);
this.root._oncreate.push(_oncreate);
if (options.target) { if (options.target) {
this._fragment.c(); this._fragment.c();
this._fragment.m(options.target, options.anchor || null); this._fragment.m(options.target, options.anchor || null);

@ -143,7 +143,7 @@ function _set(newState) {
} }
function callAll(fns) { function callAll(fns) {
while (fns && fns.length) fns.pop()(); while (fns && fns.length) fns.shift()();
} }
function _mount(target, anchor) { function _mount(target, anchor) {

@ -163,7 +163,7 @@ function _set(newState) {
} }
function callAll(fns) { function callAll(fns) {
while (fns && fns.length) fns.pop()(); while (fns && fns.length) fns.shift()();
} }
function _mount(target, anchor) { function _mount(target, anchor) {

@ -143,7 +143,7 @@ function _set(newState) {
} }
function callAll(fns) { function callAll(fns) {
while (fns && fns.length) fns.pop()(); while (fns && fns.length) fns.shift()();
} }
function _mount(target, anchor) { function _mount(target, anchor) {

@ -167,7 +167,7 @@ function _set(newState) {
} }
function callAll(fns) { function callAll(fns) {
while (fns && fns.length) fns.pop()(); while (fns && fns.length) fns.shift()();
} }
function _mount(target, anchor) { function _mount(target, anchor) {

@ -163,7 +163,7 @@ function _set(newState) {
} }
function callAll(fns) { function callAll(fns) {
while (fns && fns.length) fns.pop()(); while (fns && fns.length) fns.shift()();
} }
function _mount(target, anchor) { function _mount(target, anchor) {

@ -2,16 +2,16 @@ export default {
'skip-ssr': true, // TODO delete this line, once binding works 'skip-ssr': true, // TODO delete this line, once binding works
html: ` html: `
<p>y: foo</p> <p>y: bar</p>
<p>y: foo</p> <p>y: bar</p>
`, `,
test ( assert, component, target ) { test ( assert, component, target ) {
component.set({ x: false }); component.set({ x: false });
assert.htmlEqual( target.innerHTML, ` assert.htmlEqual( target.innerHTML, `
<p>y: foo</p> <p>y: bar</p>
<p>y: foo</p> <p>y: bar</p>
` ); ` );
} }
}; };

@ -0,0 +1,11 @@
<p>{{name}}</p>
<script>
import result from './result.js';
export default {
oncreate() {
result.push(`oncreate ${this.get('name')}`);
}
};
</script>

@ -0,0 +1,13 @@
import result from './result.js';
export default {
test(assert) {
assert.deepEqual(result, [
'oncreate foo',
'oncreate bar'
]);
result.pop();
result.pop();
}
};

@ -0,0 +1,12 @@
<Nested name='foo'/>
<Nested name='bar'/>
<script>
import Nested from './Nested.html';
export default {
components: {
Nested
}
};
</script>
Loading…
Cancel
Save