From b2f31c3f97be2454ca57d0d1c1464aa5dd1bc766 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Wed, 22 Nov 2017 12:28:59 -0500 Subject: [PATCH] destructuring, select bindings --- src/generators/Generator.ts | 15 +++++++++------ src/generators/dom/preprocess.ts | 6 +++--- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/generators/Generator.ts b/src/generators/Generator.ts index 07c7c1135c..6ee31a881d 100644 --- a/src/generators/Generator.ts +++ b/src/generators/Generator.ts @@ -776,12 +776,15 @@ export default class Generator { contextDependencies = new Map(contextDependencies); contextDependencies.set(node.context, node.dependencies); - // if (node.destructuredContexts) { - // for (let i = 0; i < node.destructuredContexts.length; i += 1) { - // contexts.set(node.destructuredContexts[i], `${context}[${i}]`); - // contextDependencies.set(node.destructuredContexts[i], dependencies); - // } - // } + if (node.destructuredContexts) { + for (let i = 0; i < node.destructuredContexts.length; i += 1) { + const name = node.destructuredContexts[i]; + const value = `${node.context}[${i}]`; + + // contexts.set(node.destructuredContexts[i], `${context}[${i}]`); + contextDependencies.set(name, node.dependencies); + } + } contextDependenciesStack.push(contextDependencies); diff --git a/src/generators/dom/preprocess.ts b/src/generators/dom/preprocess.ts index 57fda53e95..5c0ede1193 100644 --- a/src/generators/dom/preprocess.ts +++ b/src/generators/dom/preprocess.ts @@ -375,10 +375,10 @@ const preprocessors = { // so that if `foo.qux` changes, we know that we need to // mark `bar` and `baz` as dirty too if (node.name === 'select') { - if (valueAttribute) { + const binding = node.attributes.find((node: Node) => node.type === 'Binding' && node.name === 'value'); + if (binding) { // TODO does this also apply to e.g. ``? - const dependencies = valueAttribute.dependencies; - console.log({ dependencies }); + const dependencies = binding.dependencies; state.selectBindingDependencies = dependencies; dependencies.forEach((prop: string) => { generator.indirectDependencies.set(prop, new Set());