fix(vue): do not add invalid semicolon for event attr (#5418)
This commit is contained in:
3 files changed
+41
-1
No files matched your search
@@ -910,7 +910,9 @@ function printEmbeddedAttributeValue(node, originalTextToDoc, options) {
|
||||
const fnExpRE = /^([\w$_]+|\([^)]*?\))\s*=>|^function\s*\(/;
|
||||
const simplePathRE = /^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*|\['[^']*?']|\["[^"]*?"]|\[\d+]|\[[A-Za-z_$][\w$]*])*$/;
|
||||
|
||||
const value = getValue();
|
||||
const value = getValue()
|
||||
// https://github.com/vuejs/vue/blob/v2.5.17/src/compiler/helpers.js#L104
|
||||
.trim();
|
||||
return printMaybeHug(
|
||||
simplePathRE.test(value) || fnExpRE.test(value)
|
||||
? textToDoc(value, { parser: "__js_expression" })
|
||||
|
||||
@@ -25,6 +25,12 @@ exports[`attributes.vue - vue-verify 1`] = `
|
||||
:class="(() => { return 'hello' })()"
|
||||
:key="index /* hello */ "
|
||||
:key="index // hello "
|
||||
@click="() => {console.log(test)}"
|
||||
@click="
|
||||
() => {
|
||||
console.log(test);
|
||||
}
|
||||
"
|
||||
></div>
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
<div
|
||||
@@ -71,6 +77,16 @@ exports[`attributes.vue - vue-verify 1`] = `
|
||||
:key="
|
||||
index // hello
|
||||
"
|
||||
@click="
|
||||
() => {
|
||||
console.log(test);
|
||||
}
|
||||
"
|
||||
@click="
|
||||
() => {
|
||||
console.log(test);
|
||||
}
|
||||
"
|
||||
></div>
|
||||
|
||||
`;
|
||||
@@ -100,6 +116,12 @@ exports[`attributes.vue - vue-verify 2`] = `
|
||||
:class="(() => { return 'hello' })()"
|
||||
:key="index /* hello */ "
|
||||
:key="index // hello "
|
||||
@click="() => {console.log(test)}"
|
||||
@click="
|
||||
() => {
|
||||
console.log(test);
|
||||
}
|
||||
"
|
||||
></div>
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
<div
|
||||
@@ -146,6 +168,16 @@ exports[`attributes.vue - vue-verify 2`] = `
|
||||
:key="
|
||||
index // hello
|
||||
"
|
||||
@click="
|
||||
() => {
|
||||
console.log(test);
|
||||
}
|
||||
"
|
||||
@click="
|
||||
() => {
|
||||
console.log(test);
|
||||
}
|
||||
"
|
||||
></div>
|
||||
|
||||
`;
|
||||
|
||||
@@ -22,4 +22,10 @@
|
||||
:class="(() => { return 'hello' })()"
|
||||
:key="index /* hello */ "
|
||||
:key="index // hello "
|
||||
@click="() => {console.log(test)}"
|
||||
@click="
|
||||
() => {
|
||||
console.log(test);
|
||||
}
|
||||
"
|
||||
></div>
|
||||
Reference in new issue
Block a user