Skip to content

Commit

Permalink
fix: allow aria and dashed attributes
Browse files Browse the repository at this point in the history
closes #59
  • Loading branch information
elevatebart committed Nov 13, 2020
1 parent abd8229 commit c9f5fbc
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 1 deletion.
54 changes: 54 additions & 0 deletions src/utils/__tests__/checkTemplate.js
Original file line number Diff line number Diff line change
Expand Up @@ -246,3 +246,57 @@ test("parse v-for nested expressions and add their vars to available data", () =
})
).not.toThrow();
});

test("throw error when mixed case attributes", () => {
expect(() =>
checkTemplate({
template: `<div aA="as">
<div/>
</div>`,
})
).toThrowError("[VueLive] Invalid attribute name: aA");
});

test("throw error when invalid character attributes", () => {
expect(() =>
checkTemplate({
template: `<div $s="as">
<div/>
</div>`,
})
).toThrowError("[VueLive] Invalid attribute name: $s");
});

test("throw error when invalid character attributes", () => {
expect(() =>
checkTemplate({
template: `<div $s="as">
<div/>
</div>`,
})
).toThrowError("[VueLive] Invalid attribute name: $s");
});

test("throw error when invalid character attributes", () => {
expect(() =>
checkTemplate({
template: `<div s:tata="as">
<div/>
</div>`,
})
).toThrowError("[VueLive] Invalid attribute name: s:tata");
});

test("not error when all attributes are valid", () => {
expect(() =>
checkTemplate({
template: `<div>
<div ja-da="0" />
<div v-bind:da="0" />
<div v-on:da="0" />
<div :da="0" />
<div @da="co()" />
</div>`,
})
).not.toThrow();
});
File renamed without changes.
2 changes: 1 addition & 1 deletion src/utils/checkTemplate.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export default function($options, checkVariableAvailability) {
const templateVars = [];
if (templateAst.type === ELEMENT) {
templateAst.props.forEach((attr) => {
if (!/^[a-z,-,:]+$/g.test(attr.name)) {
if (!/^[a-z-]+$/g.test(attr.name)) {
throw new VueLiveParseTemplateAttrError(
"[VueLive] Invalid attribute name: " + attr.name,
attr.loc
Expand Down

0 comments on commit c9f5fbc

Please sign in to comment.