tidy up indirectDependencies stuff a bit

pull/924/head
Rich Harris 8 years ago
parent f31eed460d
commit 1e34cca54f

@ -300,16 +300,6 @@ export default class Generator {
const dependencies: Set<string> = new Set(expression._dependencies || []); const dependencies: Set<string> = new Set(expression._dependencies || []);
if (expression._dependencies) {
expression._dependencies.forEach((prop: string) => {
if (this.indirectDependencies.has(prop)) {
this.indirectDependencies.get(prop).forEach(dependency => {
dependencies.add(dependency);
});
}
});
}
return { return {
dependencies: Array.from(dependencies), dependencies: Array.from(dependencies),
contexts: usedContexts, contexts: usedContexts,
@ -661,8 +651,7 @@ export default class Generator {
walkTemplate() { walkTemplate() {
const { const {
expectedProperties, expectedProperties,
helpers, helpers
indirectDependencies
} = this; } = this;
const { html } = this.parsed; const { html } = this.parsed;
@ -701,13 +690,6 @@ export default class Generator {
dependencies.forEach(dependency => { dependencies.forEach(dependency => {
expectedProperties.add(dependency); expectedProperties.add(dependency);
// TODO looks like this needs to happen in a subsequent pass?
if (indirectDependencies.has(dependency)) {
indirectDependencies.get(dependency).forEach(indirectDependency => {
dependencies.add(indirectDependency);
});
}
}); });
return Array.from(dependencies); return Array.from(dependencies);

@ -96,17 +96,20 @@ export default function addBindings(
binding.value binding.value
); );
// TODO tidy up // special case: if you have e.g. `<input type=checkbox bind:checked=selected.done>`
let dependencies = new Set(binding.dependencies); // and `selected` is an object chosen with a <select>, then when `checked` changes,
binding.dependencies.forEach(prop => { // we need to tell the component to update all the values `selected` might be
// pointing to
// TODO should this happen in preprocess?
const dependencies = binding.dependencies.slice();
binding.dependencies.forEach((prop: string) => {
const indirectDependencies = generator.indirectDependencies.get(prop); const indirectDependencies = generator.indirectDependencies.get(prop);
if (indirectDependencies) { if (indirectDependencies) {
indirectDependencies.forEach(indirectDependency => { indirectDependencies.forEach(indirectDependency => {
dependencies.add(indirectDependency); if (!~dependencies.indexOf(indirectDependency)) dependencies.push(indirectDependency);
}); });
} }
}); });
dependencies = Array.from(dependencies);
contexts.forEach(context => { contexts.forEach(context => {
if (!~state.allUsedContexts.indexOf(context)) if (!~state.allUsedContexts.indexOf(context))

Loading…
Cancel
Save