pull/715/merge
Yury Zhuravlev 8 years ago committed by GitHub
commit 9859429364

@ -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) {

@ -197,19 +197,24 @@ function SvelteComponent ( options ) {
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 ) {
this._fragment.create(); this._fragment.create();
this._fragment.mount( options.target, null ); this._fragment.mount( options.target, null );
} else {
this._protectDomUpdate = true;
} }
this._protectDomUpdate = false;
} }
assign( SvelteComponent.prototype, proto ); assign( SvelteComponent.prototype, proto );
SvelteComponent.prototype._set = function _set ( newState ) { SvelteComponent.prototype._set = function _set ( newState, withoutDomUpdate ) {
var oldState = this._state; var oldState = this._state;
this._state = assign( {}, oldState, newState ); this._state = assign( {}, oldState, newState );
dispatchObservers( this, this._observers.pre, newState, oldState ); dispatchObservers( this, this._observers.pre, newState, oldState );
this._fragment.update( newState, this._state );
withoutDomUpdate || this._fragment.update( newState, this._state );
dispatchObservers( this, this._observers.post, newState, oldState ); dispatchObservers( this, this._observers.post, newState, oldState );
}; };

@ -67,19 +67,24 @@ function SvelteComponent ( options ) {
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 ) {
this._fragment.create(); this._fragment.create();
this._fragment.mount( options.target, null ); this._fragment.mount( options.target, null );
} else {
this._protectDomUpdate = true;
} }
this._protectDomUpdate = false;
} }
assign( SvelteComponent.prototype, proto ); assign( SvelteComponent.prototype, proto );
SvelteComponent.prototype._set = function _set ( newState ) { SvelteComponent.prototype._set = function _set ( newState, withoutDomUpdate ) {
var oldState = this._state; var oldState = this._state;
this._state = assign( {}, oldState, newState ); this._state = assign( {}, oldState, newState );
dispatchObservers( this, this._observers.pre, newState, oldState ); dispatchObservers( this, this._observers.pre, newState, oldState );
this._fragment.update( newState, this._state );
withoutDomUpdate || this._fragment.update( newState, this._state );
dispatchObservers( this, this._observers.post, newState, oldState ); dispatchObservers( this, this._observers.post, newState, oldState );
}; };

@ -154,15 +154,19 @@ function SvelteComponent ( options ) {
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 ) {
this._fragment.create(); this._fragment.create();
this._fragment.mount( options.target, null ); this._fragment.mount( options.target, null );
} else {
this._protectDomUpdate = true;
} }
this._protectDomUpdate = false;
} }
assign( SvelteComponent.prototype, proto ); assign( SvelteComponent.prototype, proto );
SvelteComponent.prototype._set = function _set ( newState ) { SvelteComponent.prototype._set = function _set ( newState, withoutDomUpdate ) {
var oldState = this._state; var oldState = this._state;
this._state = assign( {}, oldState, newState ); this._state = assign( {}, oldState, newState );
recompute( this._state, newState, oldState, false ); recompute( this._state, newState, oldState, false );

@ -48,15 +48,19 @@ function SvelteComponent ( options ) {
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 ) {
this._fragment.create(); this._fragment.create();
this._fragment.mount( options.target, null ); this._fragment.mount( options.target, null );
} else {
this._protectDomUpdate = true;
} }
this._protectDomUpdate = false;
} }
assign( SvelteComponent.prototype, proto ); assign( SvelteComponent.prototype, proto );
SvelteComponent.prototype._set = function _set ( newState ) { SvelteComponent.prototype._set = function _set ( newState, withoutDomUpdate ) {
var oldState = this._state; var oldState = this._state;
this._state = assign( {}, oldState, newState ); this._state = assign( {}, oldState, newState );
recompute( this._state, newState, oldState, false ) recompute( this._state, newState, oldState, false )

@ -300,19 +300,24 @@ function SvelteComponent ( options ) {
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 ) {
this._fragment.create(); this._fragment.create();
this._fragment.mount( options.target, null ); this._fragment.mount( options.target, null );
} else {
this._protectDomUpdate = true;
} }
this._protectDomUpdate = false;
} }
assign( SvelteComponent.prototype, proto ); assign( SvelteComponent.prototype, proto );
SvelteComponent.prototype._set = function _set ( newState ) { SvelteComponent.prototype._set = function _set ( newState, withoutDomUpdate ) {
var oldState = this._state; var oldState = this._state;
this._state = assign( {}, oldState, newState ); this._state = assign( {}, oldState, newState );
dispatchObservers( this, this._observers.pre, newState, oldState ); dispatchObservers( this, this._observers.pre, newState, oldState );
this._fragment.update( newState, this._state );
withoutDomUpdate || this._fragment.update( newState, this._state );
dispatchObservers( this, this._observers.post, newState, oldState ); dispatchObservers( this, this._observers.post, newState, oldState );
}; };

@ -161,19 +161,24 @@ function SvelteComponent ( options ) {
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 ) {
this._fragment.create(); this._fragment.create();
this._fragment.mount( options.target, null ); this._fragment.mount( options.target, null );
} else {
this._protectDomUpdate = true;
} }
this._protectDomUpdate = false;
} }
assign( SvelteComponent.prototype, proto ); assign( SvelteComponent.prototype, proto );
SvelteComponent.prototype._set = function _set ( newState ) { SvelteComponent.prototype._set = function _set ( newState, withoutDomUpdate ) {
var oldState = this._state; var oldState = this._state;
this._state = assign( {}, oldState, newState ); this._state = assign( {}, oldState, newState );
dispatchObservers( this, this._observers.pre, newState, oldState ); dispatchObservers( this, this._observers.pre, newState, oldState );
this._fragment.update( newState, this._state );
withoutDomUpdate || this._fragment.update( newState, this._state );
dispatchObservers( this, this._observers.post, newState, oldState ); dispatchObservers( this, this._observers.post, newState, oldState );
}; };

@ -189,15 +189,19 @@ function SvelteComponent ( options ) {
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 ) {
this._fragment.create(); this._fragment.create();
this._fragment.mount( options.target, null ); this._fragment.mount( options.target, null );
} else {
this._protectDomUpdate = true;
} }
this._protectDomUpdate = false;
} }
assign( SvelteComponent.prototype, template.methods, proto ); assign( SvelteComponent.prototype, template.methods, proto );
SvelteComponent.prototype._set = function _set ( newState ) { SvelteComponent.prototype._set = function _set ( newState, withoutDomUpdate ) {
var oldState = this._state; var oldState = this._state;
this._state = assign( {}, oldState, newState ); this._state = assign( {}, oldState, newState );
dispatchObservers( this, this._observers.pre, newState, oldState ); dispatchObservers( this, this._observers.pre, newState, oldState );

@ -65,15 +65,19 @@ function SvelteComponent ( options ) {
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 ) {
this._fragment.create(); this._fragment.create();
this._fragment.mount( options.target, null ); this._fragment.mount( options.target, null );
} else {
this._protectDomUpdate = true;
} }
this._protectDomUpdate = false;
} }
assign( SvelteComponent.prototype, template.methods, proto ); assign( SvelteComponent.prototype, template.methods, proto );
SvelteComponent.prototype._set = function _set ( newState ) { SvelteComponent.prototype._set = function _set ( newState, withoutDomUpdate ) {
var oldState = this._state; var oldState = this._state;
this._state = assign( {}, oldState, newState ); this._state = assign( {}, oldState, newState );
dispatchObservers( this, this._observers.pre, newState, oldState ); dispatchObservers( this, this._observers.pre, newState, oldState );

@ -235,19 +235,24 @@ function SvelteComponent ( options ) {
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 ) {
this._fragment.create(); this._fragment.create();
this._fragment.mount( options.target, null ); this._fragment.mount( options.target, null );
} else {
this._protectDomUpdate = true;
} }
this._protectDomUpdate = false;
} }
assign( SvelteComponent.prototype, proto ); assign( SvelteComponent.prototype, proto );
SvelteComponent.prototype._set = function _set ( newState ) { SvelteComponent.prototype._set = function _set ( newState, withoutDomUpdate ) {
var oldState = this._state; var oldState = this._state;
this._state = assign( {}, oldState, newState ); this._state = assign( {}, oldState, newState );
dispatchObservers( this, this._observers.pre, newState, oldState ); dispatchObservers( this, this._observers.pre, newState, oldState );
this._fragment.update( newState, this._state );
withoutDomUpdate || this._fragment.update( newState, this._state );
dispatchObservers( this, this._observers.post, newState, oldState ); dispatchObservers( this, this._observers.post, newState, oldState );
}; };

@ -105,19 +105,24 @@ function SvelteComponent ( options ) {
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 ) {
this._fragment.create(); this._fragment.create();
this._fragment.mount( options.target, null ); this._fragment.mount( options.target, null );
} else {
this._protectDomUpdate = true;
} }
this._protectDomUpdate = false;
} }
assign( SvelteComponent.prototype, proto ); assign( SvelteComponent.prototype, proto );
SvelteComponent.prototype._set = function _set ( newState ) { SvelteComponent.prototype._set = function _set ( newState, withoutDomUpdate ) {
var oldState = this._state; var oldState = this._state;
this._state = assign( {}, oldState, newState ); this._state = assign( {}, oldState, newState );
dispatchObservers( this, this._observers.pre, newState, oldState ); dispatchObservers( this, this._observers.pre, newState, oldState );
this._fragment.update( newState, this._state );
withoutDomUpdate || this._fragment.update( newState, this._state );
dispatchObservers( this, this._observers.post, newState, oldState ); dispatchObservers( this, this._observers.post, newState, oldState );
}; };

@ -211,19 +211,24 @@ function SvelteComponent ( options ) {
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 ) {
this._fragment.create(); this._fragment.create();
this._fragment.mount( options.target, null ); this._fragment.mount( options.target, null );
} else {
this._protectDomUpdate = true;
} }
this._protectDomUpdate = false;
} }
assign( SvelteComponent.prototype, proto ); assign( SvelteComponent.prototype, proto );
SvelteComponent.prototype._set = function _set ( newState ) { SvelteComponent.prototype._set = function _set ( newState, withoutDomUpdate ) {
var oldState = this._state; var oldState = this._state;
this._state = assign( {}, oldState, newState ); this._state = assign( {}, oldState, newState );
dispatchObservers( this, this._observers.pre, newState, oldState ); dispatchObservers( this, this._observers.pre, newState, oldState );
this._fragment.update( newState, this._state );
withoutDomUpdate || this._fragment.update( newState, this._state );
dispatchObservers( this, this._observers.post, newState, oldState ); dispatchObservers( this, this._observers.post, newState, oldState );
}; };

@ -81,19 +81,24 @@ function SvelteComponent ( options ) {
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 ) {
this._fragment.create(); this._fragment.create();
this._fragment.mount( options.target, null ); this._fragment.mount( options.target, null );
} else {
this._protectDomUpdate = true;
} }
this._protectDomUpdate = false;
} }
assign( SvelteComponent.prototype, proto ); assign( SvelteComponent.prototype, proto );
SvelteComponent.prototype._set = function _set ( newState ) { SvelteComponent.prototype._set = function _set ( newState, withoutDomUpdate ) {
var oldState = this._state; var oldState = this._state;
this._state = assign( {}, oldState, newState ); this._state = assign( {}, oldState, newState );
dispatchObservers( this, this._observers.pre, newState, oldState ); dispatchObservers( this, this._observers.pre, newState, oldState );
this._fragment.update( newState, this._state );
withoutDomUpdate || this._fragment.update( newState, this._state );
dispatchObservers( this, this._observers.post, newState, oldState ); dispatchObservers( this, this._observers.post, newState, oldState );
}; };

@ -182,17 +182,21 @@ function SvelteComponent ( options ) {
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 ) {
this._fragment.create(); this._fragment.create();
this._fragment.mount( options.target, null ); this._fragment.mount( options.target, null );
} else {
this._protectDomUpdate = true;
} }
callAll(this._oncreate); callAll(this._oncreate);
this._protectDomUpdate = false;
} }
assign( SvelteComponent.prototype, proto ); assign( SvelteComponent.prototype, proto );
SvelteComponent.prototype._set = function _set ( newState ) { SvelteComponent.prototype._set = function _set ( newState, withoutDomUpdate ) {
var oldState = this._state; var oldState = this._state;
this._state = assign( {}, oldState, newState ); this._state = assign( {}, oldState, newState );
dispatchObservers( this, this._observers.pre, newState, oldState ); dispatchObservers( this, this._observers.pre, newState, oldState );

@ -66,17 +66,21 @@ function SvelteComponent ( options ) {
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 ) {
this._fragment.create(); this._fragment.create();
this._fragment.mount( options.target, null ); this._fragment.mount( options.target, null );
} else {
this._protectDomUpdate = true;
} }
callAll(this._oncreate); callAll(this._oncreate);
this._protectDomUpdate = false;
} }
assign( SvelteComponent.prototype, proto ); assign( SvelteComponent.prototype, proto );
SvelteComponent.prototype._set = function _set ( newState ) { SvelteComponent.prototype._set = function _set ( newState, withoutDomUpdate ) {
var oldState = this._state; var oldState = this._state;
this._state = assign( {}, oldState, newState ); this._state = assign( {}, oldState, newState );
dispatchObservers( this, this._observers.pre, newState, oldState ); dispatchObservers( this, this._observers.pre, newState, oldState );

@ -145,10 +145,14 @@ function SvelteComponent ( options ) {
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 ) {
this._fragment.create(); this._fragment.create();
this._fragment.mount( options.target, null ); this._fragment.mount( options.target, null );
} else {
this._protectDomUpdate = true;
} }
this._protectDomUpdate = false;
if ( options._root ) { if ( options._root ) {
options._root._oncreate.push( template.oncreate.bind( this ) ); options._root._oncreate.push( template.oncreate.bind( this ) );
@ -159,7 +163,7 @@ function SvelteComponent ( options ) {
assign( SvelteComponent.prototype, proto ); assign( SvelteComponent.prototype, proto );
SvelteComponent.prototype._set = function _set ( newState ) { SvelteComponent.prototype._set = function _set ( newState, withoutDomUpdate ) {
var oldState = this._state; var oldState = this._state;
this._state = assign( {}, oldState, newState ); this._state = assign( {}, oldState, newState );
dispatchObservers( this, this._observers.pre, newState, oldState ); dispatchObservers( this, this._observers.pre, newState, oldState );

@ -39,10 +39,14 @@ function SvelteComponent ( options ) {
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 ) {
this._fragment.create(); this._fragment.create();
this._fragment.mount( options.target, null ); this._fragment.mount( options.target, null );
} else {
this._protectDomUpdate = true;
} }
this._protectDomUpdate = false;
if ( options._root ) { if ( options._root ) {
options._root._oncreate.push( template.oncreate.bind( this ) ); options._root._oncreate.push( template.oncreate.bind( this ) );
@ -53,7 +57,7 @@ function SvelteComponent ( options ) {
assign( SvelteComponent.prototype, proto ); assign( SvelteComponent.prototype, proto );
SvelteComponent.prototype._set = function _set ( newState ) { SvelteComponent.prototype._set = function _set ( newState, withoutDomUpdate ) {
var oldState = this._state; var oldState = this._state;
this._state = assign( {}, oldState, newState ); this._state = assign( {}, oldState, newState );
dispatchObservers( this, this._observers.pre, newState, oldState ); dispatchObservers( this, this._observers.pre, newState, oldState );

@ -395,19 +395,24 @@ function SvelteComponent ( options ) {
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 ) {
this._fragment.create(); this._fragment.create();
this._fragment.mount( options.target, null ); this._fragment.mount( options.target, null );
} else {
this._protectDomUpdate = true;
} }
this._protectDomUpdate = false;
} }
assign( SvelteComponent.prototype, proto ); assign( SvelteComponent.prototype, proto );
SvelteComponent.prototype._set = function _set ( newState ) { SvelteComponent.prototype._set = function _set ( newState, withoutDomUpdate ) {
var oldState = this._state; var oldState = this._state;
this._state = assign( {}, oldState, newState ); this._state = assign( {}, oldState, newState );
dispatchObservers( this, this._observers.pre, newState, oldState ); dispatchObservers( this, this._observers.pre, newState, oldState );
this._fragment.update( newState, this._state );
withoutDomUpdate || this._fragment.update( newState, this._state );
dispatchObservers( this, this._observers.post, newState, oldState ); dispatchObservers( this, this._observers.post, newState, oldState );
}; };

@ -265,19 +265,24 @@ function SvelteComponent ( options ) {
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 ) {
this._fragment.create(); this._fragment.create();
this._fragment.mount( options.target, null ); this._fragment.mount( options.target, null );
} else {
this._protectDomUpdate = true;
} }
this._protectDomUpdate = false;
} }
assign( SvelteComponent.prototype, proto ); assign( SvelteComponent.prototype, proto );
SvelteComponent.prototype._set = function _set ( newState ) { SvelteComponent.prototype._set = function _set ( newState, withoutDomUpdate ) {
var oldState = this._state; var oldState = this._state;
this._state = assign( {}, oldState, newState ); this._state = assign( {}, oldState, newState );
dispatchObservers( this, this._observers.pre, newState, oldState ); dispatchObservers( this, this._observers.pre, newState, oldState );
this._fragment.update( newState, this._state );
withoutDomUpdate || this._fragment.update( newState, this._state );
dispatchObservers( this, this._observers.post, newState, oldState ); dispatchObservers( this, this._observers.post, newState, oldState );
}; };

@ -0,0 +1,20 @@
<Two bind:foo/>
<p class="{{test ? 't1' : 't2'}}"></p>
<script>
import Two from './Two.html';
export default {
data() {
return {
test: false
};
},
components: {
Two
},
oncreate() {
this.snapshot = this.get('foo');
}
};
</script>

@ -0,0 +1,15 @@
<script>
export default {
data() {
return {
bar: 1
};
},
computed: {
foo(bar) {
return bar * 2;
}
}
};
</script>

@ -0,0 +1,5 @@
export default {
test(assert, component) {
assert.equal(component.refs.one.snapshot, 2);
}
};

@ -0,0 +1,9 @@
<One ref:one/>
<script>
import One from './One.html';
export default {
components: { One }
};
</script>
Loading…
Cancel
Save