use hasOwnProperty, simplify prop object construction

pull/3811/head
Richard Harris 6 years ago
parent 47a9811c1e
commit de2b1a6a0d

@ -425,16 +425,9 @@ export default function dom(
`);
}
const prop_names = x`{}` as ObjectExpression;
// TODO find a more idiomatic way of doing this
props.forEach(v => {
prop_names.properties.push(
v.name === v.export_name
? p`${v.name}: 0`
: p`${v.export_name}: "${v.name}"`
);
});
const prop_names = x`{
${props.map(v => p`${v.export_name}: ${v.export_name === v.name ? 0 : x`"${v.name}"`}}`)}
}` as ObjectExpression;
if (options.customElement) {
const declaration = b`

@ -22,7 +22,7 @@ interface T$$ {
}
export function bind(component, name, callback) {
if (name in component.$$.props) {
if (component.$$.props.hasOwnProperty(name)) {
name = component.$$.props[name] || name;
component.$$.bound[name] = callback;
callback(component.$$.ctx[name]);

Loading…
Cancel
Save