+36
-11
lines changedFilter options
+36
-11
lines changed Original file line number Diff line number Diff line change
@@ -11,12 +11,11 @@
11
11
12
12
import { makeMap, no } from 'shared/util'
13
13
import { isNonPhrasingTag } from 'web/compiler/util'
14
+
import { unicodeLetters } from 'core/util/lang'
14
15
15
16
// Regular Expressions for parsing tags and attributes
16
17
const attribute = /^\s*([^\s"'<>\/=]+)(?:\s*(=)\s*(?:"([^"]*)"+|'([^']*)'+|([^\s"'=<>`]+)))?/
17
-
// could use https://www.w3.org/TR/1999/REC-xml-names-19990114/#NT-QName
18
-
// but for Vue templates we can enforce a simple charset
19
-
const ncname = '[a-zA-Z_][\\w\\-\\.]*'
18
+
const ncname = `[a-zA-Z_][\\-\\.0-9_a-zA-Z${unicodeLetters}]*`
20
19
const qnameCapture = `((?:${ncname}\\:)?${ncname})`
21
20
const startTagOpen = new RegExp(`^<${qnameCapture}`)
22
21
const startTagClose = /^\s*(\/?)>/
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
1
1
/* @flow */
2
2
3
+
/**
4
+
* unicode letters used for parsing html tags, component names and property paths.
5
+
* using https://www.w3.org/TR/html53/semantics-scripting.html#potentialcustomelementname
6
+
* skipping \u10000-\uEFFFF due to it freezing up PhantomJS
7
+
*/
8
+
export const unicodeLetters = 'a-zA-Z\u00B7\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u037D\u037F-\u1FFF\u200C-\u200D\u203F-\u2040\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD'
9
+
3
10
/**
4
11
* Check if a string starts with $ or _
5
12
*/
@@ -23,7 +30,7 @@ export function def (obj: Object, key: string, val: any, enumerable?: boolean) {
23
30
/**
24
31
* Parse simple path.
25
32
*/
26
-
const bailRE = /[^\w.$]/
33
+
const bailRE = new RegExp(`[^${unicodeLetters}.$]`)
27
34
export function parsePath (path: string): any {
28
35
if (bailRE.test(path)) {
29
36
return
Original file line number Diff line number Diff line change
@@ -2,9 +2,9 @@
2
2
3
3
import config from '../config'
4
4
import { warn } from './debug'
5
-
import { nativeWatch } from './env'
6
5
import { set } from '../observer/index'
7
-
import { hasSymbol } from '../util/index'
6
+
import { unicodeLetters } from './lang'
7
+
import { nativeWatch, hasSymbol } from './env'
8
8
9
9
import {
10
10
ASSET_TYPES,
@@ -264,11 +264,10 @@ function checkComponents (options: Object) {
264
264
}
265
265
266
266
export function validateComponentName (name: string) {
267
-
if (!/^[a-zA-Z][\w-]*$/.test(name)) {
267
+
if (!new RegExp(`^[a-zA-Z][\\-\\.0-9_${unicodeLetters}]*$`).test(name)) {
268
268
warn(
269
269
'Invalid component name: "' + name + '". Component names ' +
270
-
'can only contain alphanumeric characters and the hyphen, ' +
271
-
'and must start with a letter.'
270
+
'should conform to valid custom element name in html5 specification.'
272
271
)
273
272
}
274
273
if (isBuiltInTag(name) || config.isReservedTag(name)) {
Original file line number Diff line number Diff line change
@@ -26,6 +26,9 @@ describe('Instance methods data', () => {
26
26
data: {
27
27
a: {
28
28
b: 1
29
+
},
30
+
유니코드: {
31
+
なまえ: 'ok'
29
32
}
30
33
},
31
34
methods: {
@@ -108,6 +111,15 @@ describe('Instance methods data', () => {
108
111
expect(spy).toHaveBeenCalledWith(1)
109
112
})
110
113
114
+
it('handler option in string', () => {
115
+
vm.$watch('유니코드.なまえ', {
116
+
handler: 'foo',
117
+
immediate: true
118
+
})
119
+
expect(spy.calls.count()).toBe(1)
120
+
expect(spy).toHaveBeenCalledWith('ok')
121
+
})
122
+
111
123
it('warn expression', () => {
112
124
vm.$watch('a + b', spy)
113
125
expect('Watcher only accepts simple dot-delimited paths').toHaveBeenWarned()
Original file line number Diff line number Diff line change
@@ -15,7 +15,7 @@ describe('Options name', () => {
15
15
})
16
16
17
17
/* eslint-disable */
18
-
expect(`Invalid component name: "Hyper*Vue". Component names can only contain alphanumeric characters and the hyphen, and must start with a letter.`)
18
+
expect(`Invalid component name: "Hyper*Vue".`)
19
19
.toHaveBeenWarned()
20
20
/* eslint-enable */
21
21
@@ -24,7 +24,7 @@ describe('Options name', () => {
24
24
})
25
25
26
26
/* eslint-disable */
27
-
expect(`Invalid component name: "2Cool2BValid". Component names can only contain alphanumeric characters and the hyphen, and must start with a letter.`)
27
+
expect(`Invalid component name: "2Cool2BValid".`)
28
28
.toHaveBeenWarned()
29
29
/* eslint-enable */
30
30
})
@@ -37,4 +37,12 @@ describe('Options name', () => {
37
37
expect(SuperComponent.options.components['SuperVue']).toEqual(SuperComponent)
38
38
expect(SuperComponent.options.components['super-component']).toEqual(SuperComponent)
39
39
})
40
+
41
+
it('should allow all potential custom element name for component name including non-alphanumeric characters', () => {
42
+
Vue.extend({
43
+
name: 'my-컴포넌트'
44
+
})
45
+
46
+
expect(`Invalid component name`).not.toHaveBeenWarned()
47
+
})
40
48
})
You can’t perform that action at this time.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4