Avoid update DOM during Bind init if parent component is not exist.

pull/715/head
Yury Zhuravlev 8 years ago
parent 06ba4cd332
commit 177e4f8049

@ -123,7 +123,8 @@ export default function dom(
${computations.length && ${computations.length &&
`@recompute( this._state, newState, oldState, false )`} `@recompute( this._state, newState, oldState, false )`}
@dispatchObservers( this, this._observers.pre, newState, oldState ); @dispatchObservers( this, this._observers.pre, newState, oldState );
${block.hasUpdateMethod && `this._fragment.update( newState, this._state );`}
${block.hasUpdateMethod && `withoutDomUpdate || this._fragment.update( newState, this._state );`}
@dispatchObservers( this, this._observers.post, newState, oldState ); @dispatchObservers( this, this._observers.post, newState, oldState );
${generator.hasComponents && `@callAll(this._oncreate);`} ${generator.hasComponents && `@callAll(this._oncreate);`}
${generator.hasComplexBindings && `@callAll(this._bindings);`} ${generator.hasComplexBindings && `@callAll(this._bindings);`}
@ -213,6 +214,7 @@ export default function dom(
this._fragment = @create_main_fragment( this._state, this ); this._fragment = @create_main_fragment( this._state, this );
this._protectDomUpdate = false;
if ( options.target ) { if ( options.target ) {
${generator.hydratable ${generator.hydratable
? deindent` ? deindent`
@ -225,10 +227,13 @@ export default function dom(
this._fragment.create(); this._fragment.create();
`} `}
this._fragment.${block.hasIntroMethod ? 'intro' : 'mount'}( options.target, null ); this._fragment.${block.hasIntroMethod ? 'intro' : 'mount'}( options.target, null );
} else {
this._protectDomUpdate = true;
} }
${generator.hasComponents && `@callAll(this._oncreate);`} ${generator.hasComponents && `@callAll(this._oncreate);`}
${generator.hasComplexBindings && `@callAll(this._bindings);`} ${generator.hasComplexBindings && `@callAll(this._bindings);`}
this._protectDomUpdate = false;
${templateProperties.oncreate && deindent` ${templateProperties.oncreate && deindent`
if ( options._root ) { if ( options._root ) {
@ -242,7 +247,7 @@ export default function dom(
@assign( ${prototypeBase}, ${proto}); @assign( ${prototypeBase}, ${proto});
${name}.prototype._set = function _set ( newState ) { ${name}.prototype._set = function _set ( newState, withoutDomUpdate ) {
${_set} ${_set}
}; };

@ -29,10 +29,10 @@ export default function getSetter({
${computed ${computed
? `#component._set({ ${dependencies ? `#component._set({ ${dependencies
.map((prop: string) => `${prop}: state.${prop}`) .map((prop: string) => `${prop}: state.${prop}`)
.join(', ')} });` .join(', ')} }, #component._protectDomUpdate);`
: `#component._set({ ${dependencies : `#component._set({ ${dependencies
.map((prop: string) => `${prop}: #component.get( '${prop}' )`) .map((prop: string) => `${prop}: #component.get( '${prop}' )`)
.join(', ')} });`} .join(', ')} }, #component._protectDomUpdate);`}
`; `;
} }
@ -42,11 +42,11 @@ export default function getSetter({
${snippet} = ${value}; ${snippet} = ${value};
#component._set({ ${dependencies #component._set({ ${dependencies
.map((prop: string) => `${prop}: state.${prop}`) .map((prop: string) => `${prop}: state.${prop}`)
.join(', ')} }); .join(', ')} }, #component._protectDomUpdate);
`; `;
} }
return `#component._set({ ${name}: ${value} });`; return `#component._set({ ${name}: ${value} }, #component._protectDomUpdate);`;
} }
function isComputed(node: Node) { function isComputed(node: Node) {

Loading…
Cancel
Save