Component.$unsafe_set

pull/3005/head
Timothy Johnson 6 years ago
parent 0e1cb29c1e
commit 126c515d22

@ -75,6 +75,7 @@ export default function dom(
const $$props = uses_props ? `$$new_props` : `$$props`;
const props = component.vars.filter(variable => !variable.module && variable.export_name);
const writable_props = props.filter(variable => variable.writable);
const writable_vars = component.vars.filter(variable => !variable.module && variable.writable);
/* eslint-disable @typescript-eslint/indent,indent */
const set = (uses_props || writable_props.length > 0 || component.slots.size > 0)
@ -89,6 +90,16 @@ export default function dom(
}
`
: null;
const unsafe_set = writable_vars.length > 0
? deindent`
$$values => {
${writable_vars.map(variable =>
`if ('${variable.name}' in $$values) ${component.invalidate(variable.name, `${variable.name} = $$values.${variable.name}`)};`
)}
}
`
: null;
/* eslint-enable @typescript-eslint/indent,indent */
const body = [];
@ -430,6 +441,8 @@ export default function dom(
${set && `$$self.$set = ${set};`}
${unsafe_set && component.compile_options.dev && `$$self.$unsafe_set = ${unsafe_set};`}
${injected.length && `let ${injected.join(', ')};`}
${reactive_declarations.length > 0 && deindent`

Loading…
Cancel
Save