merge master -> gh-177

pull/324/head
Rich Harris 8 years ago
commit ee5e8e8afa

@ -322,7 +322,7 @@ export default function dom ( parsed, source, options, names ) {
if ( options.dev ) {
Object.keys( generator.expectedProperties ).forEach( prop => {
constructorBlock.addLine(
`if ( !( '${prop}' in this._state ) ) throw new Error( "Component was created without expected data property 'foo'" );`
`if ( !( '${prop}' in this._state ) ) throw new Error( "Component was created without expected data property '${prop}'" );`
);
});

@ -72,6 +72,8 @@ export default function createBinding ( generator, node, attribute, current, loc
}
} while ( fragment = fragment.parent );
generator.expectedProperties[ prop ] = true;
const listName = current.listNames[ parts[0] ];
const indexName = current.indexNames[ parts[0] ];
@ -84,7 +86,8 @@ export default function createBinding ( generator, node, attribute, current, loc
component._set({ ${prop}: component.get( '${prop}' ) });
`;
} else if ( deep ) {
} else {
if ( deep ) {
setter = deindent`
var ${parts[0]} = component.get( '${parts[0]}' );
${parts[0]}.${parts.slice( 1 ).join( '.' )} = ${value};
@ -94,6 +97,9 @@ export default function createBinding ( generator, node, attribute, current, loc
setter = `component._set({ ${attribute.value}: ${value} });`;
}
generator.expectedProperties[ parts[0] ] = true;
}
// special case
if ( node.name === 'select' ) {
setter = `var selectedOption = ${local.name}.selectedOptions[0] || ${local.name}.options[0];\n` + setter;

@ -0,0 +1,7 @@
export default {
dev: true,
error ( assert, err ) {
assert.equal( err.message, `Component was created without expected data property 'value'` );
}
};
Loading…
Cancel
Save