Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 8da7f03

Browse files
mysticateamichalsnik
authored andcommitted
Fix: crash no-v-invalid-v-for on :key (fixes #37) (#39)
1 parent 47532e2 commit 8da7f03

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

‎lib/rules/no-invalid-v-for.js‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ const utils = require('../utils')
2121
* @returns {boolean} `true` if the node is using the variables which are defined by `v-for` directives.
2222
*/
2323
function isUsingIterationVar (node) {
24+
if (node.value == null) {
25+
return false
26+
}
2427
const references = node.value.references
2528
const variables = node.parent.parent.variables
2629

‎tests/lib/rules/no-invalid-v-for.js‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,11 @@ tester.run('no-invalid-v-for', rule, {
144144
filename: 'test.vue',
145145
code: '<template><div><custom-component v-for="x in list" :key="foo"></custom-component></div></template>',
146146
errors: ["Expected 'v-bind:key' directive to use the variables which are defined by the 'v-for' directive."]
147+
},
148+
{
149+
filename: 'test.vue',
150+
code: '<template><div><div v-for="(item, index) in suggestions" :key></div></div></template>',
151+
errors: ["Expected 'v-bind:key' directive to use the variables which are defined by the 'v-for' directive."]
147152
}
148153
]
149154
})

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /