diff --git a/src/compile/Component.ts b/src/compile/Component.ts index 659cf972cc..fa980593a3 100644 --- a/src/compile/Component.ts +++ b/src/compile/Component.ts @@ -1002,7 +1002,8 @@ export default class Component { const object = getObject(node); const { name } = object; - if (name[0] === '$' || component.var_lookup.has(name)) { + const owner = scope.findOwner(name); + if ((!owner || owner === component.instance_scope) && (name[0] === '$' || component.var_lookup.has(name))) { dependencies.add(name); } diff --git a/test/runtime/samples/reactive-values-non-cyclical/_config.js b/test/runtime/samples/reactive-values-non-cyclical/_config.js new file mode 100644 index 0000000000..e134a669ee --- /dev/null +++ b/test/runtime/samples/reactive-values-non-cyclical/_config.js @@ -0,0 +1,17 @@ +export default { + props: { + x: 42 + }, + + html: ` +

42 42

+ `, + + test({ assert, component, target }) { + component.x = 43; + + assert.htmlEqual(target.innerHTML, ` +

43 43

+ `); + } +}; diff --git a/test/runtime/samples/reactive-values-non-cyclical/main.html b/test/runtime/samples/reactive-values-non-cyclical/main.html new file mode 100644 index 0000000000..061a38857a --- /dev/null +++ b/test/runtime/samples/reactive-values-non-cyclical/main.html @@ -0,0 +1,13 @@ + + +

{a} {b}

\ No newline at end of file diff --git a/test/validator/samples/reactive-declaration-cyclical/errors.json b/test/validator/samples/reactive-declaration-cyclical/errors.json new file mode 100644 index 0000000000..1e4169a0ee --- /dev/null +++ b/test/validator/samples/reactive-declaration-cyclical/errors.json @@ -0,0 +1,7 @@ +[{ + "message": "Cyclical dependency detected", + "code": "cyclical-reactive-declaration", + "start": { "line": 5, "column": 1, "character": 35 }, + "end": { "line": 5, "column": 14, "character": 48 }, + "pos": 35 +}] \ No newline at end of file diff --git a/test/validator/samples/reactive-declaration-cyclical/input.html b/test/validator/samples/reactive-declaration-cyclical/input.html new file mode 100644 index 0000000000..c8221b9aa8 --- /dev/null +++ b/test/validator/samples/reactive-declaration-cyclical/input.html @@ -0,0 +1,7 @@ + \ No newline at end of file