Merge pull request #1530 from sveltejs/gh-1522

onstate before render
pull/1662/head
Rich Harris 6 years ago committed by GitHub
commit b62872d39c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -224,11 +224,12 @@ export default function dom(
${compiler.slots.size && `this.slots = {};`}
${templateProperties.onstate && `%onstate.call(this, { changed: @assignTrue({}, this._state), current: this._state });`}
this._fragment = @create_main_fragment(this, this._state);
${hasInitHooks && deindent`
this.root._oncreate.push(() => {
${templateProperties.onstate && `%onstate.call(this, { changed: @assignTrue({}, this._state), current: this._state });`}
${templateProperties.oncreate && `%oncreate.call(this);`}
this.fire("update", { changed: @assignTrue({}, this._state), current: this._state });
});

@ -0,0 +1,16 @@
import order from './order.js';
export default {
'skip-ssr': true,
test(assert, component, target) {
assert.deepEqual(order, [
'onstate',
'render',
'oncreate',
'onupdate'
]);
order.length = 0;
}
};

@ -0,0 +1,26 @@
{identity(42)}
<script>
import order from './order.js';
export default {
helpers: {
identity(x) {
order.push('render');
return x;
}
},
onstate() {
order.push('onstate');
},
onupdate() {
order.push('onupdate');
},
oncreate() {
order.push('oncreate');
}
};
</script>
Loading…
Cancel
Save