Skip to content

Commit c9f5fbc

Browse files
committed
fix: allow aria and dashed attributes
closes #59
1 parent abd8229 commit c9f5fbc

File tree

3 files changed

+55
-1
lines changed

3 files changed

+55
-1
lines changed

src/utils/__tests__/checkTemplate.js

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,3 +246,57 @@ test("parse v-for nested expressions and add their vars to available data", () =
246246
})
247247
).not.toThrow();
248248
});
249+
250+
test("throw error when mixed case attributes", () => {
251+
expect(() =>
252+
checkTemplate({
253+
template: `<div aA="as">
254+
<div/>
255+
</div>`,
256+
})
257+
).toThrowError("[VueLive] Invalid attribute name: aA");
258+
});
259+
260+
test("throw error when invalid character attributes", () => {
261+
expect(() =>
262+
checkTemplate({
263+
template: `<div $s="as">
264+
<div/>
265+
</div>`,
266+
})
267+
).toThrowError("[VueLive] Invalid attribute name: $s");
268+
});
269+
270+
test("throw error when invalid character attributes", () => {
271+
expect(() =>
272+
checkTemplate({
273+
template: `<div $s="as">
274+
<div/>
275+
</div>`,
276+
})
277+
).toThrowError("[VueLive] Invalid attribute name: $s");
278+
});
279+
280+
test("throw error when invalid character attributes", () => {
281+
expect(() =>
282+
checkTemplate({
283+
template: `<div s:tata="as">
284+
<div/>
285+
</div>`,
286+
})
287+
).toThrowError("[VueLive] Invalid attribute name: s:tata");
288+
});
289+
290+
test("not error when all attributes are valid", () => {
291+
expect(() =>
292+
checkTemplate({
293+
template: `<div>
294+
<div ja-da="0" />
295+
<div v-bind:da="0" />
296+
<div v-on:da="0" />
297+
<div :da="0" />
298+
<div @da="co()" />
299+
</div>`,
300+
})
301+
).not.toThrow();
302+
});

src/utils/checkTemplate.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export default function($options, checkVariableAvailability) {
4949
const templateVars = [];
5050
if (templateAst.type === ELEMENT) {
5151
templateAst.props.forEach((attr) => {
52-
if (!/^[a-z,-,:]+$/g.test(attr.name)) {
52+
if (!/^[a-z-]+$/g.test(attr.name)) {
5353
throw new VueLiveParseTemplateAttrError(
5454
"[VueLive] Invalid attribute name: " + attr.name,
5555
attr.loc

0 commit comments

Comments
 (0)