Merge branch 'master' into refactor

pull/453/head
Rich-Harris 8 years ago
commit 731f09d173

@ -193,7 +193,7 @@ export default function dom ( parsed, source, options ) {
constructorBlock.addBlock( generator.builders.metaBindings ); constructorBlock.addBlock( generator.builders.metaBindings );
} }
if ( templateProperties.computed ) { if ( computations.length ) {
constructorBlock.addLine( constructorBlock.addLine(
`${generator.alias( 'recompute' )}( this._state, this._state, {}, true );` `${generator.alias( 'recompute' )}( this._state, this._state, {}, true );`
); );

@ -12,7 +12,7 @@ export function fire ( eventName, data ) {
} }
export function observe ( key, callback, options ) { export function observe ( key, callback, options ) {
var group = ( options && options.defer ) ? this._observers.pre : this._observers.post; var group = ( options && options.defer ) ? this._observers.post : this._observers.pre;
( group[ key ] || ( group[ key ] = [] ) ).push( callback ); ( group[ key ] || ( group[ key ] = [] ) ).push( callback );

@ -0,0 +1,8 @@
export default {
html: '<div>empty</div>',
test ( assert, component, target ) {
assert.equal( component.get( 'created' ), true );
assert.equal( target.innerHTML, '<div>empty</div>' );
component.destroy();
}
};

@ -0,0 +1,14 @@
<div>empty</div>
<script>
export default {
data () {
return {};
},
computed: {},
oncreate () {
this.set({ created: true });
}
};
</script>

@ -0,0 +1,22 @@
export default {
'skip-ssr': true,
data: {
value: 'hello!'
},
html: `
<p>hello!</p>
<p>hello!</p>
`,
test ( assert, component, target ) {
component.set({ value: 'goodbye!' });
assert.htmlEqual( target.innerHTML, `
<p>goodbye!</p>
<p>goodbye!</p>
` );
component.destroy();
}
};

@ -0,0 +1,14 @@
<p ref:a>{{value}}</p>
<p ref:b></p>
<script>
export default {
oncreate () {
this.observe( 'value', () => {
this.refs.b.textContent = this.refs.a.textContent;
}, {
defer: true
});
}
};
</script>

@ -138,6 +138,8 @@ describe( 'runtime', () => {
assert.htmlEqual( target.innerHTML, config.html ); assert.htmlEqual( target.innerHTML, config.html );
} }
Object.assign = Object_assign;
if ( config.test ) { if ( config.test ) {
config.test( assert, component, target, window ); config.test( assert, component, target, window );
} else { } else {

Loading…
Cancel
Save