-
Notifications
You must be signed in to change notification settings - Fork 396
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(template-compiler): omit api_key for key outside iteration (#2699)
* fix(template-compiler): omit api_key for key outside iteration * fix: improve warning message
- Loading branch information
1 parent
ddb9404
commit fc2fd37
Showing
6 changed files
with
33 additions
and
18 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
11 changes: 5 additions & 6 deletions
11
.../@lwc/template-compiler/src/__tests__/fixtures/directive-key/outside-iterator/expected.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 |
---|---|---|
@@ -1,11 +1,10 @@ | ||
import { registerTemplate } from "lwc"; | ||
const stc0 = { | ||
key: 0, | ||
}; | ||
function tmpl($api, $cmp, $slotset, $ctx) { | ||
const { k: api_key, h: api_element } = $api; | ||
return [ | ||
api_element("div", { | ||
key: api_key(0, $cmp.keyGetter), | ||
}), | ||
]; | ||
const { h: api_element } = $api; | ||
return [api_element("div", stc0)]; | ||
} | ||
export default registerTemplate(tmpl); | ||
tmpl.stylesheets = []; |
14 changes: 13 additions & 1 deletion
14
...lwc/template-compiler/src/__tests__/fixtures/directive-key/outside-iterator/metadata.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 |
---|---|---|
@@ -1,3 +1,15 @@ | ||
{ | ||
"warnings": [] | ||
"warnings": [ | ||
{ | ||
"code": 1149, | ||
"message": "LWC1149: Invalid key attribute on element <div>. The key attribute should be applied to an element with for:each or iterator:*, or to a direct child of a <template> element with for:each or iterator:*. This key will be ignored, and may throw an error in future versions of LWC.", | ||
"level": 2, | ||
"location": { | ||
"line": 2, | ||
"column": 10, | ||
"start": 20, | ||
"length": 15 | ||
} | ||
} | ||
] | ||
} |
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