Skip to content

Commit 3d9b61b

Browse files
committed
2 parents 4005077 + acdcf24 commit 3d9b61b

18 files changed

+4186
-4
lines changed

lib/transform-html.js

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -524,9 +524,9 @@ class HTMLTransformer {
524524
result.id = this.createVIdentifier(result, start + 1)
525525

526526
for (const attr of attrs) {
527-
const name = attr.name
527+
const name = attr.prefix ? `${attr.prefix}:${attr.name}` : attr.name
528528
const value = attr.value
529-
const attrLoc = attrLocs[name]
529+
const attrLoc = attrLocs[name.toLowerCase()]
530530
const attribute =
531531
this.createVAttribute(result, name, value, attrLoc)
532532

@@ -629,6 +629,26 @@ class HTMLTransformer {
629629
* @returns {ASTNode|ASTNode[]} The transformed node.
630630
*/
631631
visitElementNode(parent, node) {
632+
// if __location does not exists, this is auto-inserted element for some reason.
633+
// E.g. if a <tr> exists as a direct child of <table>, <tbody> element is inserted implicitly.
634+
if (node.__location == null) {
635+
const results = []
636+
for (const childNode of node.childNodes) {
637+
const child = this.visit(parent, childNode)
638+
639+
// Flatten.
640+
if (Array.isArray(child)) {
641+
for (const child1 of child) {
642+
results.push(child1)
643+
}
644+
}
645+
else if (child != null) {
646+
results.push(child)
647+
}
648+
}
649+
return results
650+
}
651+
632652
const start = node.__location.startOffset
633653
const end = node.__location.endOffset
634654
const childNodes = (node.tagName === "template")

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vue-eslint-parser",
3-
"version": "1.1.0-6",
3+
"version": "1.1.0-7",
44
"description": "The ESLint custom parser for `.vue` files.",
55
"engines": {
66
"node": ">=4"
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<template>
2+
<div>
3+
<svg viewBox="0 0 40 40"></svg>
4+
</div>
5+
</template>
6+
7+
<script>
8+
module.exports = {}
9+
</script>

test/fixtures/svg-attrs-colon.vue

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<template>
2+
<svg>
3+
<use xlink:href="#test"></use>
4+
</svg>
5+
</template>
6+
7+
<script>
8+
module.exports = {}
9+
</script>

0 commit comments

Comments
 (0)