enforce order of operations

pull/709/head
Rich Harris 8 years ago
parent d893f8fc28
commit 0a806585b3

@ -235,9 +235,15 @@ export default function dom(
this._fragment.${block.hasIntroMethod ? 'intro' : 'mount'}( options.target, null );
}
${(generator.hasComponents || generator.hasComplexBindings || templateProperties.oncreate || generator.hasIntroTransitions) && deindent`
if ( !options._root ) {
${generator.hasComponents && `this._block = true;`}
${(generator.hasComponents || generator.hasComplexBindings) && `@callAll(this._beforecreate);`}
${(generator.hasComponents || templateProperties.oncreate) && `@callAll(this._oncreate);`}
${(generator.hasComponents || generator.hasIntroTransitions) && `@callAll(this._aftercreate);`}
${generator.hasComponents && `this._block = false;`}
}
`}
}
@assign( ${prototypeBase}, ${proto});

@ -27,10 +27,10 @@ export default function getSetter({
list[index]${tail} = ${value};
${computed
? `#component._set({ ${dependencies
? `#component.set({ ${dependencies
.map((prop: string) => `${prop}: state.${prop}`)
.join(', ')} });`
: `#component._set({ ${dependencies
: `#component.set({ ${dependencies
.map((prop: string) => `${prop}: #component.get( '${prop}' )`)
.join(', ')} });`}
`;
@ -40,13 +40,13 @@ export default function getSetter({
return deindent`
var state = #component.get();
${snippet} = ${value};
#component._set({ ${dependencies
#component.set({ ${dependencies
.map((prop: string) => `${prop}: state.${prop}`)
.join(', ')} });
`;
}
return `#component._set({ ${name}: ${value} });`;
return `#component.set({ ${name}: ${value} });`;
}
function isComputed(node: Node) {

@ -106,9 +106,12 @@ export function onDev(eventName, handler) {
export function set(newState) {
this._set(assign({}, newState));
if (this._root._block) return;
this._root._block = true;
callAll(this._root._beforecreate);
callAll(this._root._oncreate);
callAll(this._root._aftercreate);
this._root._block = false;
}
export function callAll(fns) {

Loading…
Cancel
Save