Skip to content

Commit

Permalink
Issue139 (#141)
Browse files Browse the repository at this point in the history
* Add test covering viewBox (#139)

* If standard key doesn't work, try lowercase (fix #139)

* Add .editorconfig

see https://editorconfig.org

* Fix for prettier lint warning

Co-authored-by: Calvin Juárez <[email protected]>
  • Loading branch information
calvinjuarez and Calvin Juárez authored Jun 24, 2020
1 parent 71c4633 commit 836f07d
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
7 changes: 7 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# EditorConfig.org

root = true

[*]
indent_size = 4
indent_style = space
6 changes: 5 additions & 1 deletion lib/services/html-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,11 @@ const TOKEN_BUILDERS = {
const key = attr.prefix
? `${attr.prefix}:${attr.name}`
: attr.name
const attrLoc = location.startTag.attrs[key]
// https://github.com/ota-meshi/eslint-plugin-lodash-template/issues/139
const attrLoc =
key in location.startTag.attrs
? location.startTag.attrs[key]
: location.startTag.attrs[key.toLowerCase()] // fix for viewBox and other camelCase attributes in SVG
const attrToken = new HTMLAttribute(
html,
attrLoc.startOffset,
Expand Down
5 changes: 5 additions & 0 deletions tests/lib/rules/attribute-name-casing.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ tester.run("attribute-name-casing", rule, {
filename: "test.html",
code: '<svg xml:space="preserve"></svg>',
},
{
filename: "test-viewbox.html",
code: '<svg viewBox="0 0 100 100"></svg>',
options: [{ ignore: ["viewBox"] }],
},
],

invalid: [
Expand Down

0 comments on commit 836f07d

Please sign in to comment.