Skip to content

Commit ddf5471

Browse files
committed
Add better character range for attributes
1 parent 1d2edb2 commit ddf5471

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ module.exports = function (h, opts) {
160160
state = ATTR
161161
} else if (state === OPEN) {
162162
reg += c
163-
} else if (state === ATTR && /[\w-]/.test(c)) {
163+
} else if (state === ATTR && /[^\s"'=/]/.test(c)) {
164164
state = ATTR_KEY
165165
reg = c
166166
} else if (state === ATTR && /\s/.test(c)) {

test/attr.js

+12
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,15 @@ test('consecutive unquoted attributes', function (t) {
6262
t.equal(vdom.create(tree).toString(), '<div id="test" class="test"></div>')
6363
t.end()
6464
})
65+
66+
test('strange leading character attributes', function (t) {
67+
var tree = hx`<div @click='test' :href='/foo'></div>`
68+
t.equal(vdom.create(tree).toString(), '<div @click="test" :href="/foo"></div>')
69+
t.end()
70+
})
71+
72+
test('strange inbetween character attributes', function (t) {
73+
var tree = hx`<div f@o='bar' b&z='qux'></div>`
74+
t.equal(vdom.create(tree).toString(), `<div f@o="bar" b&z="qux"></div>`)
75+
t.end()
76+
})

0 commit comments

Comments
 (0)