Only capture and inject writable props

pull/3126/head
Axelen123 6 years ago
parent f69abde570
commit d64521cf42
No known key found for this signature in database
GPG Key ID: 7B3388EF6070C533

@ -154,14 +154,14 @@ export default function dom(
capture_state = (uses_props || writable_props.length > 0) ? deindent` capture_state = (uses_props || writable_props.length > 0) ? deindent`
() => { () => {
return { ${component.vars.map(prop => prop.name).join(", ")} }; return { ${component.vars.filter(prop => prop.writable).map(prop => prop.name).join(", ")} };
} }
` : null; ` : null;
inject_state = (uses_props || writable_props.length > 0) ? deindent` inject_state = (uses_props || writable_props.length > 0) ? deindent`
${$$props} => { ${$$props} => {
${uses_props && component.invalidate('$$props', `$$props = @assign(@assign({}, $$props), $$new_props)`)} ${uses_props && component.invalidate('$$props', `$$props = @assign(@assign({}, $$props), $$new_props)`)}
${component.vars.map(prop => deindent` ${component.vars.filter(prop => prop.writable).map(prop => deindent`
if ('${prop.name}' in $$props) ${component.invalidate(prop.name, `${prop.name} = ${$$props}.${prop.name}`)}; if ('${prop.name}' in $$props) ${component.invalidate(prop.name, `${prop.name} = ${$$props}.${prop.name}`)};
`)} `)}
} }

Loading…
Cancel
Save