diff --git a/src/compile/nodes/shared/Expression.ts b/src/compile/nodes/shared/Expression.ts index 0d33988fb3..eb6b12143a 100644 --- a/src/compile/nodes/shared/Expression.ts +++ b/src/compile/nodes/shared/Expression.ts @@ -150,7 +150,7 @@ export default class Expression { } component.add_reference(name); - component.warn_if_undefined(nodes[0], template_scope, true); + component.warn_if_undefined(nodes[0], template_scope); } this.skip(); diff --git a/src/compile/render-dom/wrappers/InlineComponent/index.ts b/src/compile/render-dom/wrappers/InlineComponent/index.ts index 327eee59cf..979b09d612 100644 --- a/src/compile/render-dom/wrappers/InlineComponent/index.ts +++ b/src/compile/render-dom/wrappers/InlineComponent/index.ts @@ -1,7 +1,6 @@ import Wrapper from '../shared/Wrapper'; import Renderer from '../../Renderer'; import Block from '../../Block'; -import Node from '../../../nodes/shared/Node'; import InlineComponent from '../../../nodes/InlineComponent'; import FragmentWrapper from '../Fragment'; import { quoteNameIfNecessary, quotePropIfNecessary } from '../../../../utils/quoteIfNecessary'; @@ -85,7 +84,16 @@ export default class InlineComponentWrapper extends Wrapper { }); this.fragment = new FragmentWrapper(renderer, default_slot, node.children, this, stripWhitespace, nextSibling); - block.addDependencies(default_slot.dependencies); + const dependencies = new Set(); + + // TODO is this filtering necessary? (I *think* so) + default_slot.dependencies.forEach(name => { + if (!this.node.scope.is_let(name)) { + dependencies.add(name); + } + }); + + block.addDependencies(dependencies); } block.addOutro(); @@ -160,7 +168,9 @@ export default class InlineComponentWrapper extends Wrapper { }); }); - if (!usesSpread && (this.node.attributes.filter(a => a.isDynamic).length || this.node.bindings.length || fragment_dependencies.size > 0)) { + const non_let_dependencies = Array.from(fragment_dependencies).filter(name => !this.node.scope.is_let(name)); + + if (!usesSpread && (this.node.attributes.filter(a => a.isDynamic).length || this.node.bindings.length || non_let_dependencies.length > 0)) { updates.push(`var ${name_changes} = {};`); } @@ -231,8 +241,8 @@ export default class InlineComponentWrapper extends Wrapper { } } - if (fragment_dependencies.size > 0) { - updates.push(`if (${Array.from(fragment_dependencies).map(n => `changed.${n}`).join(' || ')}) ${name_changes}.$$scope = { changed, ctx };`); + if (non_let_dependencies.length > 0) { + updates.push(`if (${non_let_dependencies.map(n => `changed.${n}`).join(' || ')}) ${name_changes}.$$scope = { changed, ctx };`); } const munged_bindings = this.node.bindings.map(binding => { @@ -482,6 +492,7 @@ export default class InlineComponentWrapper extends Wrapper { `); if (updates.length) { + console.log({ updates }); block.builders.update.addBlock(deindent` ${updates} ${name}.$set(${name_changes}); @@ -498,13 +509,4 @@ export default class InlineComponentWrapper extends Wrapper { ); } } -} - -function isComputed(node: Node) { - while (node.type === 'MemberExpression') { - if (node.computed) return true; - node = node.object; - } - - return false; -} +} \ No newline at end of file