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 || []);
if (expression._dependencies) {
expression._dependencies.forEach((prop: string) => {
if (this.indirectDependencies.has(prop)) {
this.indirectDependencies.get(prop).forEach(dependency => {
dependencies.add(dependency);
});
}
});
}
return {
dependencies: Array.from(dependencies),
contexts: usedContexts,
@ -661,8 +651,7 @@ export default class Generator {
walkTemplate() {
const {
expectedProperties,
helpers,
indirectDependencies
helpers
} = this;
const { html } = this.parsed;
@ -701,13 +690,6 @@ export default class Generator {
dependencies.forEach(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);

@ -96,17 +96,20 @@ export default function addBindings(
binding.value
);
// TODO tidy up
let dependencies = new Set(binding.dependencies);
binding.dependencies.forEach(prop => {
// special case: if you have e.g. `<input type=checkbox bind:checked=selected.done>`
// and `selected` is an object chosen with a <select>, then when `checked` changes,
// 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);
if (indirectDependencies) {
indirectDependencies.forEach(indirectDependency => {
dependencies.add(indirectDependency);
if (!~dependencies.indexOf(indirectDependency)) dependencies.push(indirectDependency);
});
}
});
dependencies = Array.from(dependencies);
contexts.forEach(context => {
if (!~state.allUsedContexts.indexOf(context))

Loading…
Cancel
Save