From 587d1f8994a2c7851d7dd88f08a609dd64897534 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Tue, 29 Aug 2017 21:51:07 -0400 Subject: [PATCH] remove some unused code --- src/generators/dom/preprocess.ts | 10 ++-------- src/generators/dom/visitors/Element/Element.ts | 11 ----------- src/generators/server-side-rendering/index.ts | 2 -- .../server-side-rendering/visitors/Component.ts | 4 ---- .../server-side-rendering/visitors/Element.ts | 4 ---- src/generators/server-side-rendering/visitors/Slot.ts | 4 ---- 6 files changed, 2 insertions(+), 33 deletions(-) diff --git a/src/generators/dom/preprocess.ts b/src/generators/dom/preprocess.ts index 6beca924ff..7855a52f89 100644 --- a/src/generators/dom/preprocess.ts +++ b/src/generators/dom/preprocess.ts @@ -341,8 +341,7 @@ const preprocessors = { node._state = getChildState(state, { name, - parentNode: `${name}._slotted.default`, - isYield: true + parentNode: `${name}._slotted.default` }); } else { const slot = getStaticAttributeValue(node, 'slot'); @@ -373,12 +372,7 @@ const preprocessors = { if (node.children.length) { if (isComponent) { - const name = block.getUniqueName( - (node.name === ':Self' ? generator.name : node.name).toLowerCase() - ); - - if (node.children) node._slots = new Set(['default']); // TODO only include default if there are unslotted children - + if (node.children) node._slots = new Set(['default']); preprocessChildren(generator, block, node._state, node, inEachBlock, elementStack, componentStack.concat(node), stripWhitespace, nextSibling); } else { if (node.name === 'pre' || node.name === 'textarea') stripWhitespace = false; diff --git a/src/generators/dom/visitors/Element/Element.ts b/src/generators/dom/visitors/Element/Element.ts index f0e97d9f15..1087273406 100644 --- a/src/generators/dom/visitors/Element/Element.ts +++ b/src/generators/dom/visitors/Element/Element.ts @@ -208,17 +208,6 @@ export default function visitElement( } if (node.initialUpdate) { - // special case — if we're in a yield block, then we may call mount - // long after the fragment is created. We may therefore need to get - // the latest `state` object - // TODO what about contexts in yield blocks? do we need to do - // `var ${contextName} = [something complicated]`? - const needsStateObject = node.initialUpdateNeedsStateObject && state.isYield; - - if ( needsStateObject ) { - block.builders.mount.addLine(`var state = #component.get()`); - } - block.builders.mount.addBlock(node.initialUpdate); } diff --git a/src/generators/server-side-rendering/index.ts b/src/generators/server-side-rendering/index.ts index 9419bde3d5..16492fa386 100644 --- a/src/generators/server-side-rendering/index.ts +++ b/src/generators/server-side-rendering/index.ts @@ -11,7 +11,6 @@ import { stringify } from '../../utils/stringify'; export class SsrGenerator extends Generator { bindings: string[]; renderCode: string; - elementDepth: number; // TODO is this necessary? appears to be unused appendTargets: Record | null; appendTarget: string | null; @@ -25,7 +24,6 @@ export class SsrGenerator extends Generator { super(parsed, source, name, stylesheet, options); this.bindings = []; this.renderCode = ''; - this.elementDepth = 0; this.appendTargets = null; // in an SSR context, we don't need to include events, methods, oncreate or ondestroy diff --git a/src/generators/server-side-rendering/visitors/Component.ts b/src/generators/server-side-rendering/visitors/Component.ts index eb3dbf4f14..4c476055fa 100644 --- a/src/generators/server-side-rendering/visitors/Component.ts +++ b/src/generators/server-side-rendering/visitors/Component.ts @@ -83,14 +83,10 @@ export default function visitComponent( generator.appendTargets = {}; generator.setAppendTarget('default'); - generator.elementDepth += 1; - node.children.forEach((child: Node) => { visit(generator, block, child); }); - generator.elementDepth -= 1; - const slotted = Object.keys(generator.appendTargets) .map(name => `${name}: () => \`${generator.appendTargets[name]}\``) .join(', '); diff --git a/src/generators/server-side-rendering/visitors/Element.ts b/src/generators/server-side-rendering/visitors/Element.ts index 7d2ba15030..94af2bed82 100644 --- a/src/generators/server-side-rendering/visitors/Element.ts +++ b/src/generators/server-side-rendering/visitors/Element.ts @@ -83,13 +83,9 @@ export default function visitElement( if (node.name === 'textarea' && textareaContents !== undefined) { generator.append(textareaContents); } else { - generator.elementDepth += 1; - node.children.forEach((child: Node) => { visit(generator, block, child); }); - - generator.elementDepth -= 1; } if (!isVoidElementName(node.name)) { diff --git a/src/generators/server-side-rendering/visitors/Slot.ts b/src/generators/server-side-rendering/visitors/Slot.ts index 9d6530fea9..ad8aaecd7b 100644 --- a/src/generators/server-side-rendering/visitors/Slot.ts +++ b/src/generators/server-side-rendering/visitors/Slot.ts @@ -14,13 +14,9 @@ export default function visitSlot( generator.append(`\${options && options.slotted && options.slotted.${slotName} ? options.slotted.${slotName}() : \``); - generator.elementDepth += 1; - node.children.forEach((child: Node) => { visit(generator, block, child); }); - generator.elementDepth -= 1; - generator.append(`\`}`); }