Skip to content

Commit cd46954

Browse files
committed
improve static considertaion for contextual variable
1 parent 563fc88 commit cd46954

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/compiler/compile/nodes/shared/Expression.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,15 @@ export default class Expression {
175175
});
176176
}
177177

178+
dynamic_contextual_dependencies() {
179+
return Array.from(this.contextual_dependencies).filter(name => {
180+
return Array.from(this.template_scope.dependencies_for_name.get(name)).some(variable_name => {
181+
const variable = this.component.var_lookup.get(variable_name);
182+
return is_dynamic(variable);
183+
});
184+
});
185+
}
186+
178187
// TODO move this into a render-dom wrapper?
179188
manipulate(block?: Block, ctx?: string | void) {
180189
// TODO ideally we wouldn't end up calling this method

src/compiler/compile/nodes/shared/Tag.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export default class Tag extends Node {
1919
);
2020
}
2121
is_dependencies_static() {
22-
return this.expression.contextual_dependencies.size === 0 && this.expression.dynamic_dependencies().length === 0;
22+
return this.expression.dynamic_contextual_dependencies().length === 0 && this.expression.dynamic_dependencies().length === 0;
2323
}
2424
check_if_content_dynamic() {
2525
if (!this.is_dependencies_static()) {

0 commit comments

Comments
 (0)