diff --git a/src/utils/__tests__/checkTemplate.js b/src/utils/__tests__/checkTemplate.js index 9041266..9d7c27e 100644 --- a/src/utils/__tests__/checkTemplate.js +++ b/src/utils/__tests__/checkTemplate.js @@ -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: `
+
+
`, + }) + ).toThrowError("[VueLive] Invalid attribute name: aA"); +}); + +test("throw error when invalid character attributes", () => { + expect(() => + checkTemplate({ + template: `
+
+
`, + }) + ).toThrowError("[VueLive] Invalid attribute name: $s"); +}); + +test("throw error when invalid character attributes", () => { + expect(() => + checkTemplate({ + template: `
+
+
`, + }) + ).toThrowError("[VueLive] Invalid attribute name: $s"); +}); + +test("throw error when invalid character attributes", () => { + expect(() => + checkTemplate({ + template: `
+
+
`, + }) + ).toThrowError("[VueLive] Invalid attribute name: s:tata"); +}); + +test("not error when all attributes are valid", () => { + expect(() => + checkTemplate({ + template: `
+
+
+
+
+
+
`, + }) + ).not.toThrow(); +}); diff --git a/src/utils/__tests__/requireAtRuntime.unit.js b/src/utils/__tests__/requireAtRuntime.js similarity index 100% rename from src/utils/__tests__/requireAtRuntime.unit.js rename to src/utils/__tests__/requireAtRuntime.js diff --git a/src/utils/checkTemplate.js b/src/utils/checkTemplate.js index 762d38b..fe7cc93 100644 --- a/src/utils/checkTemplate.js +++ b/src/utils/checkTemplate.js @@ -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