Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX: Correctly identify non-ascii JS variables in .vue files #15980

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/language-html/embed/vue-bindings.js
Expand Up @@ -19,8 +19,9 @@ function isVueEventBindingExpression(eventBindingValue) {
// arrow function or anonymous function
const fnExpRE = /^(?:[\w$]+|\([^)]*\))\s*=>|^function\s*\(/;
// simple member expression chain (a, a.b, a['b'], a["b"], a[0], a[b])

const simplePathRE =
/^[$_a-z][\w$]*(?:\.[$_a-z][\w$]*|\['[^']*']|\["[^"]*"]|\[\d+]|\[[$_a-z][\w$]*])*$/i;
/^[^\s;,]+(?:\.[^\s;,]+|\['[^']*']|\["[^"]*"]|\[\d+]|\[[^\s;,]+])*$/i;

// https://github.com/vuejs/vue/blob/v2.5.17/src/compiler/helpers.js#L104
const value = eventBindingValue.trim();
Expand Down
@@ -0,0 +1,20 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`on-click.vue format 1`] = `
====================================options=====================================
parsers: ["vue"]
printWidth: 80
| printWidth
=====================================input======================================
<template>
<div @click="我" />
<div @click="me" />
</template>
=====================================output=====================================
<template>
<div @click="我" />
<div @click="me" />
</template>

================================================================================
`;
1 change: 1 addition & 0 deletions tests/format/vue/non-ascii-character/jsfmt.spec.js
@@ -0,0 +1 @@
runFormatTest(import.meta, ["vue"]);
4 changes: 4 additions & 0 deletions tests/format/vue/non-ascii-character/on-click.vue
@@ -0,0 +1,4 @@
<template>
<div @click="我" />
<div @click="me" />
</template>