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; const prop_names = x`{
${props.map(v => p`${v.export_name}: ${v.export_name === v.name ? 0 : x`"${v.name}"`}}`)}
// TODO find a more idiomatic way of doing this }` as ObjectExpression;
props.forEach(v => {
prop_names.properties.push(
v.name === v.export_name
? p`${v.name}: 0`
: p`${v.export_name}: "${v.name}"`
);
});
if (options.customElement) { if (options.customElement) {
const declaration = b` const declaration = b`

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

Loading…
Cancel
Save