forked from sveltejs/svelte
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
warn module variables are nonreactive and make them truly nonreactive (…
- Loading branch information
Showing
7 changed files
with
79 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
test/runtime/samples/reactive-statement-module-vars/_config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
export default { | ||
html: ` | ||
a: moduleA | ||
b: moduleB | ||
moduleA: moduleA | ||
moduleB: moduleB | ||
`, | ||
async test({ assert, target, component }) { | ||
await component.updateModuleA(); | ||
|
||
assert.htmlEqual(target.innerHTML, ` | ||
a: moduleA | ||
b: moduleB | ||
moduleA: moduleA | ||
moduleB: moduleB | ||
`); | ||
} | ||
}; |
15 changes: 15 additions & 0 deletions
15
test/runtime/samples/reactive-statement-module-vars/main.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<script context="module"> | ||
let moduleA = 'moduleA'; | ||
let moduleB = 'moduleB'; | ||
</script> | ||
<script> | ||
export function updateModuleA() { | ||
moduleA = 'something else'; | ||
} | ||
$: a = moduleA; | ||
$: b = moduleB; | ||
</script> | ||
a: {a} | ||
b: {b} | ||
moduleA: {moduleA} | ||
moduleB: {moduleB} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<script context="module"> | ||
let foo; | ||
</script> | ||
<script> | ||
$: bar = foo; | ||
</script> |
17 changes: 17 additions & 0 deletions
17
test/validator/samples/reactive-module-variable/warnings.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
[ | ||
{ | ||
"code": "module-script-reactive-declaration", | ||
"message": "\"foo\" is declared in a module script and will not be reactive", | ||
"pos": 65, | ||
"start": { | ||
"character": 65, | ||
"column": 10, | ||
"line": 5 | ||
}, | ||
"end": { | ||
"character": 68, | ||
"column": 13, | ||
"line": 5 | ||
} | ||
} | ||
] |