|
|
@ -11,7 +11,7 @@ import { ClassDeclaration, FunctionExpression, Node, Statement, ObjectExpression
|
|
|
|
export default function dom(
|
|
|
|
export default function dom(
|
|
|
|
component: Component,
|
|
|
|
component: Component,
|
|
|
|
options: CompileOptions
|
|
|
|
options: CompileOptions
|
|
|
|
): { js: Node[]; css: CssResult } {
|
|
|
|
): { js: Node[]; css: CssResult; } {
|
|
|
|
const { name } = component;
|
|
|
|
const { name } = component;
|
|
|
|
|
|
|
|
|
|
|
|
const renderer = new Renderer(component, options);
|
|
|
|
const renderer = new Renderer(component, options);
|
|
|
@ -90,10 +90,10 @@ export default function dom(
|
|
|
|
${uses_rest && !uses_props && x`$$props = @assign(@assign({}, $$props), @exclude_internal_props($$new_props))`}
|
|
|
|
${uses_rest && !uses_props && x`$$props = @assign(@assign({}, $$props), @exclude_internal_props($$new_props))`}
|
|
|
|
${uses_rest && renderer.invalidate('$$restProps', x`$$restProps = ${compute_rest}`)}
|
|
|
|
${uses_rest && renderer.invalidate('$$restProps', x`$$restProps = ${compute_rest}`)}
|
|
|
|
${writable_props.map(prop =>
|
|
|
|
${writable_props.map(prop =>
|
|
|
|
b`if ('${prop.export_name}' in ${$$props}) ${renderer.invalidate(prop.name, x`${prop.name} = ${$$props}.${prop.export_name}`)};`
|
|
|
|
b`if ('${prop.export_name}' in ${$$props}) ${renderer.invalidate(prop.name, x`${prop.name} = ${$$props}.${prop.export_name}`)};`
|
|
|
|
)}
|
|
|
|
)}
|
|
|
|
${component.slots.size > 0 &&
|
|
|
|
${component.slots.size > 0 &&
|
|
|
|
b`if ('$$scope' in ${$$props}) ${renderer.invalidate('$$scope', x`$$scope = ${$$props}.$$scope`)};`}
|
|
|
|
b`if ('$$scope' in ${$$props}) ${renderer.invalidate('$$scope', x`$$scope = ${$$props}.$$scope`)};`}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`
|
|
|
|
`
|
|
|
|
: null;
|
|
|
|
: null;
|
|
|
@ -190,8 +190,8 @@ export default function dom(
|
|
|
|
${$$props} => {
|
|
|
|
${$$props} => {
|
|
|
|
${uses_props && renderer.invalidate('$$props', x`$$props = @assign(@assign({}, $$props), $$new_props)`)}
|
|
|
|
${uses_props && renderer.invalidate('$$props', x`$$props = @assign(@assign({}, $$props), $$new_props)`)}
|
|
|
|
${injectable_vars.map(
|
|
|
|
${injectable_vars.map(
|
|
|
|
v => b`if ('${v.name}' in $$props) ${renderer.invalidate(v.name, x`${v.name} = ${$$props}.${v.name}`)};`
|
|
|
|
v => b`if ('${v.name}' in $$props) ${renderer.invalidate(v.name, x`${v.name} = ${$$props}.${v.name}`)};`
|
|
|
|
)}
|
|
|
|
)}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`;
|
|
|
|
`;
|
|
|
|
|
|
|
|
|
|
|
@ -469,7 +469,7 @@ export default function dom(
|
|
|
|
$$setup(options) {
|
|
|
|
$$setup(options) {
|
|
|
|
${css.code && b`this.shadowRoot.innerHTML = \`<style>${css.code.replace(/\\/g, '\\\\')}${options.dev ? `\n/*# sourceMappingURL=${css.map.toUrl()} */` : ''}</style>\`;`}
|
|
|
|
${css.code && b`this.shadowRoot.innerHTML = \`<style>${css.code.replace(/\\/g, '\\\\')}${options.dev ? `\n/*# sourceMappingURL=${css.map.toUrl()} */` : ''}</style>\`;`}
|
|
|
|
|
|
|
|
|
|
|
|
@init(this, { props: options ? options.props : null, target: this.shadowRoot }, ${definition}, ${has_create_fragment ? 'create_fragment': 'null'}, ${not_equal}, ${prop_indexes}, ${dirty});
|
|
|
|
@init(this, { props: options ? options.props : null, target: this.shadowRoot }, ${definition}, ${has_create_fragment ? 'create_fragment' : 'null'}, ${not_equal}, ${prop_indexes}, ${dirty});
|
|
|
|
|
|
|
|
|
|
|
|
${dev_props_check}
|
|
|
|
${dev_props_check}
|
|
|
|
|
|
|
|
|
|
|
@ -521,7 +521,7 @@ export default function dom(
|
|
|
|
constructor(options) {
|
|
|
|
constructor(options) {
|
|
|
|
super(${options.dev && `options`});
|
|
|
|
super(${options.dev && `options`});
|
|
|
|
${should_add_css && b`if (!@_document.getElementById("${component.stylesheet.id}-style")) ${add_css}();`}
|
|
|
|
${should_add_css && b`if (!@_document.getElementById("${component.stylesheet.id}-style")) ${add_css}();`}
|
|
|
|
@init(this, options, ${definition}, ${has_create_fragment ? 'create_fragment': 'null'}, ${not_equal}, ${prop_indexes}, ${dirty});
|
|
|
|
@init(this, options, ${definition}, ${has_create_fragment ? 'create_fragment' : 'null'}, ${not_equal}, ${prop_indexes}, ${dirty});
|
|
|
|
${options.dev && b`@dispatch_dev("SvelteRegisterComponent", { component: this, tagName: "${name.name}", options, id: create_fragment.name });`}
|
|
|
|
${options.dev && b`@dispatch_dev("SvelteRegisterComponent", { component: this, tagName: "${name.name}", options, id: create_fragment.name });`}
|
|
|
|
|
|
|
|
|
|
|
|
${dev_props_check}
|
|
|
|
${dev_props_check}
|
|
|
|