remove renderer.slots

pull/2419/head
Richard Harris 6 years ago
parent 922c5058e3
commit 1c5c688dc5

@ -11,7 +11,6 @@ export default class Renderer {
blocks: (Block | string)[] = []; blocks: (Block | string)[] = [];
readonly: Set<string> = new Set(); readonly: Set<string> = new Set();
slots: Map<string, { slot: SlotWrapper, block: Block }> = new Map();
meta_bindings: CodeBuilder = new CodeBuilder(); // initial values for e.g. window.innerWidth, if there's a <svelte:window> meta tag meta_bindings: CodeBuilder = new CodeBuilder(); // initial values for e.g. window.innerWidth, if there's a <svelte:window> meta tag
binding_groups: string[] = []; binding_groups: string[] = [];

@ -74,14 +74,14 @@ export default function dom(
const props = component.vars.filter(variable => !variable.module && variable.export_name); const props = component.vars.filter(variable => !variable.module && variable.export_name);
const writable_props = props.filter(variable => variable.writable); const writable_props = props.filter(variable => variable.writable);
const set = (uses_props || writable_props.length > 0 || renderer.slots.size > 0) const set = (uses_props || writable_props.length > 0 || component.slots.size > 0)
? deindent` ? 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)`)}
${writable_props.map(prop => ${writable_props.map(prop =>
`if ('${prop.export_name}' in $$props) ${component.invalidate(prop.name, `${prop.name} = $$props.${prop.export_name}`)};` `if ('${prop.export_name}' in $$props) ${component.invalidate(prop.name, `${prop.name} = $$props.${prop.export_name}`)};`
)} )}
${renderer.slots.size > 0 && ${component.slots.size > 0 &&
`if ('$$scope' in ${$$props}) ${component.invalidate('$$scope', `$$scope = ${$$props}.$$scope`)};`} `if ('$$scope' in ${$$props}) ${component.invalidate('$$scope', `$$scope = ${$$props}.$$scope`)};`}
} }
` `
@ -285,7 +285,7 @@ export default function dom(
} }
const args = ['$$self']; const args = ['$$self'];
if (props.length > 0 || component.has_reactive_assignments || renderer.slots.size > 0) { if (props.length > 0 || component.has_reactive_assignments || component.slots.size > 0) {
args.push('$$props', '$$invalidate'); args.push('$$props', '$$invalidate');
} }
@ -315,7 +315,7 @@ export default function dom(
const reactive_stores = component.vars.filter(variable => variable.name[0] === '$' && variable.name[1] !== '$'); const reactive_stores = component.vars.filter(variable => variable.name[0] === '$' && variable.name[1] !== '$');
if (renderer.slots.size > 0) { if (component.slots.size > 0) {
filtered_declarations.push('$$slots', '$$scope'); filtered_declarations.push('$$slots', '$$scope');
} }
@ -415,7 +415,7 @@ export default function dom(
${component.javascript} ${component.javascript}
${renderer.slots.size && `let { $$slots = {}, $$scope } = $$props;`} ${component.slots.size && `let { $$slots = {}, $$scope } = $$props;`}
${renderer.binding_groups.length > 0 && `const $$binding_groups = [${renderer.binding_groups.map(_ => `[]`).join(', ')}];`} ${renderer.binding_groups.length > 0 && `const $$binding_groups = [${renderer.binding_groups.map(_ => `[]`).join(', ')}];`}

@ -47,8 +47,6 @@ export default class SlotWrapper extends Wrapper {
// we have to do this, just in case // we have to do this, just in case
block.add_intro(); block.add_intro();
block.add_outro(); block.add_outro();
renderer.slots.set(this.node.slot_name, { slot: this, block });
} }
render( render(

Loading…
Cancel
Save