mirror of
https://github.com/sveltejs/svelte.git
synced 2024-12-01 01:11:24 +01:00
fix missing-declaration warning for use:obj.method (#5454)
This commit is contained in:
parent
4c135b0b8d
commit
6e0cd9bcbf
@ -1,5 +1,9 @@
|
||||
# Svelte changelog
|
||||
|
||||
## Unreleased
|
||||
|
||||
* Fix erroneous `missing-declaration` warning with `use:obj.method` ([#5451](https://github.com/sveltejs/svelte/issues/5451))
|
||||
|
||||
## 3.26.0
|
||||
|
||||
* Support `use:obj.method` as actions ([#3935](https://github.com/sveltejs/svelte/issues/3935))
|
||||
|
@ -11,10 +11,11 @@ export default class Action extends Node {
|
||||
constructor(component: Component, parent, scope, info) {
|
||||
super(component, parent, scope, info);
|
||||
|
||||
component.warn_if_undefined(info.name, info, scope);
|
||||
const object = info.name.split('.')[0];
|
||||
component.warn_if_undefined(object, info, scope);
|
||||
|
||||
this.name = info.name;
|
||||
component.add_reference(info.name.split('.')[0]);
|
||||
component.add_reference(object);
|
||||
|
||||
this.expression = info.expression
|
||||
? new Expression(component, this, scope, info.expression)
|
||||
|
11
test/validator/samples/action-object/input.svelte
Normal file
11
test/validator/samples/action-object/input.svelte
Normal file
@ -0,0 +1,11 @@
|
||||
<script>
|
||||
const obj = {
|
||||
foo : "bar",
|
||||
action(element, { leet }) {
|
||||
element.foo = this.foo + leet;
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<button use:obj.action={{ leet: 1337 }}>action</button>
|
||||
<button use:foo.action={{ leet: 1337 }}>action</button>
|
17
test/validator/samples/action-object/warnings.json
Normal file
17
test/validator/samples/action-object/warnings.json
Normal file
@ -0,0 +1,17 @@
|
||||
[
|
||||
{
|
||||
"code": "missing-declaration",
|
||||
"end": {
|
||||
"character": 217,
|
||||
"column": 39,
|
||||
"line": 11
|
||||
},
|
||||
"message": "'foo' is not defined",
|
||||
"pos": 186,
|
||||
"start": {
|
||||
"character": 186,
|
||||
"column": 8,
|
||||
"line": 11
|
||||
}
|
||||
}
|
||||
]
|
Loading…
Reference in New Issue
Block a user