diff --git a/src/html/parser.ts b/src/html/parser.ts index 73c6371a..fa7d99c0 100644 --- a/src/html/parser.ts +++ b/src/html/parser.ts @@ -52,15 +52,27 @@ const DIRECTIVE_NAME = /^(?:v-|[.:@#]).*[^.:@#]$/u const DT_DD = /^d[dt]$/u const DUMMY_PARENT: any = Object.freeze({}) +/** + * Gets the tag name from the given node or token. + * For SFC, it returns the value of `rawName` to be case sensitive. + */ +function getTagName( + startTagOrElement: { name: string; rawName: string }, + isSFC: boolean, +) { + return isSFC ? startTagOrElement.rawName : startTagOrElement.name +} + /** * Check whether the element is a MathML text integration point or not. * @see https://html.spec.whatwg.org/multipage/parsing.html#tree-construction-dispatcher * @param element The current element. + * @param isSFC For SFC, give `true`. * @returns `true` if the element is a MathML text integration point. */ -function isMathMLIntegrationPoint(element: VElement): boolean { +function isMathMLIntegrationPoint(element: VElement, isSFC: boolean): boolean { if (element.namespace === NS.MathML) { - const name = element.name + const name = getTagName(element, isSFC) return ( name === "mi" || name === "mo" || @@ -76,12 +88,13 @@ function isMathMLIntegrationPoint(element: VElement): boolean { * Check whether the element is a HTML integration point or not. * @see https://html.spec.whatwg.org/multipage/parsing.html#tree-construction-dispatcher * @param element The current element. + * @param isSFC For SFC, give `true`. * @returns `true` if the element is a HTML integration point. */ -function isHTMLIntegrationPoint(element: VElement): boolean { +function isHTMLIntegrationPoint(element: VElement, isSFC: boolean): boolean { if (element.namespace === NS.MathML) { return ( - element.name === "annotation-xml" && + getTagName(element, isSFC) === "annotation-xml" && element.startTag.attributes.some( (a) => a.directive === false && @@ -93,7 +106,7 @@ function isHTMLIntegrationPoint(element: VElement): boolean { ) } if (element.namespace === NS.SVG) { - const name = element.name + const name = getTagName(element, isSFC) return name === "foreignObject" || name === "desc" || name === "title" } @@ -317,6 +330,14 @@ export class Parser { } } + /** + * Gets the tag name from the given node or token. + * For SFC, it returns the value of `rawName` to be case sensitive. + */ + private getTagName(startTagOrElement: { name: string; rawName: string }) { + return getTagName(startTagOrElement, this.isSFC) + } + /** * Detect the namespace of the new element. * @param token The StartTag token to detect. @@ -324,7 +345,7 @@ export class Parser { */ //eslint-disable-next-line complexity private detectNamespace(token: StartTag): Namespace { - const name = token.name + const name = this.getTagName(token) let ns = this.namespace if (ns === NS.MathML || ns === NS.SVG) { @@ -332,14 +353,14 @@ export class Parser { if (element.type === "VElement") { if ( element.namespace === NS.MathML && - element.name === "annotation-xml" && + this.getTagName(element) === "annotation-xml" && name === "svg" ) { return NS.SVG } if ( - isHTMLIntegrationPoint(element) || - (isMathMLIntegrationPoint(element) && + isHTMLIntegrationPoint(element, this.isSFC) || + (isMathMLIntegrationPoint(element, this.isSFC) && name !== "mglyph" && name !== "malignmark") ) { @@ -371,21 +392,23 @@ export class Parser { /** * Close the current element if necessary. - * @param name The tag name to check. + * @param token The start tag to check. */ - private closeCurrentElementIfNecessary(name: string): void { + private closeCurrentElementIfNecessary(token: StartTag): void { const element = this.currentNode if (element.type !== "VElement") { return } + const name = this.getTagName(token) + const elementName = this.getTagName(element) - if (element.name === "p" && HTML_NON_FHRASING_TAGS.has(name)) { + if (elementName === "p" && HTML_NON_FHRASING_TAGS.has(name)) { this.popElementStack() } - if (element.name === name && HTML_CAN_BE_LEFT_OPEN_TAGS.has(name)) { + if (elementName === name && HTML_CAN_BE_LEFT_OPEN_TAGS.has(name)) { this.popElementStack() } - if (DT_DD.test(element.name) && DT_DD.test(name)) { + if (DT_DD.test(elementName) && DT_DD.test(name)) { this.popElementStack() } } @@ -396,8 +419,8 @@ export class Parser { * @param namespace The current namespace. */ private processAttribute(node: VAttribute, namespace: Namespace): void { - const tagName = node.parent.parent.name - const attrName = node.key.name + const tagName = this.getTagName(node.parent.parent) + const attrName = this.getTagName(node.key) if ( (this.expressionEnabled || @@ -415,10 +438,8 @@ export class Parser { return } - const key = (node.key.name = adjustAttributeName( - node.key.name, - namespace, - )) + node.key.name = adjustAttributeName(node.key.name, namespace) + const key = this.getTagName(node.key) const value = node.value && node.value.value if (key === "xmlns" && value !== namespace) { @@ -436,7 +457,7 @@ export class Parser { protected StartTag(token: StartTag): void { debug("[html] StartTag %j", token) - this.closeCurrentElementIfNecessary(token.name) + this.closeCurrentElementIfNecessary(token) const parent = this.currentNode const namespace = this.detectNamespace(token) @@ -462,7 +483,7 @@ export class Parser { } const hasVPre = !this.isInVPreElement && - token.attributes.some((a) => a.key.name === "v-pre") + token.attributes.some((a) => this.getTagName(a.key) === "v-pre") // Disable expression if v-pre if (hasVPre) { @@ -494,7 +515,8 @@ export class Parser { // Check whether the self-closing is valid. const isVoid = - namespace === NS.HTML && HTML_VOID_ELEMENT_TAGS.has(element.name) + namespace === NS.HTML && + HTML_VOID_ELEMENT_TAGS.has(this.getTagName(element)) if (token.selfClosing && !isVoid && namespace === NS.HTML) { this.reportParseError( token, @@ -518,13 +540,14 @@ export class Parser { // Update the content type of this element. if (namespace === NS.HTML) { + const elementName = this.getTagName(element) if (element.parent.type === "VDocumentFragment") { const langAttr = element.startTag.attributes.find( (a) => !a.directive && a.key.name === "lang", ) as VAttribute | undefined const lang = langAttr?.value?.value - if (element.name === "template") { + if (elementName === "template") { if (lang && lang !== "html") { // It is not an HTML template. this.tokenizer.state = "RAWTEXT" @@ -538,18 +561,18 @@ export class Parser { this.tokenizer.state = "RAWTEXT" } } else { - if (HTML_RCDATA_TAGS.has(element.name)) { + if (HTML_RCDATA_TAGS.has(elementName)) { this.tokenizer.state = "RCDATA" } - if (HTML_RAWTEXT_TAGS.has(element.name)) { + if (HTML_RAWTEXT_TAGS.has(elementName)) { this.tokenizer.state = "RAWTEXT" } } } else { - if (HTML_RCDATA_TAGS.has(element.name)) { + if (HTML_RCDATA_TAGS.has(elementName)) { this.tokenizer.state = "RCDATA" } - if (HTML_RAWTEXT_TAGS.has(element.name)) { + if (HTML_RAWTEXT_TAGS.has(elementName)) { this.tokenizer.state = "RAWTEXT" } } diff --git a/src/template/index.ts b/src/template/index.ts index 65e4ec34..19374d1a 100644 --- a/src/template/index.ts +++ b/src/template/index.ts @@ -6,6 +6,7 @@ import sortedIndexBy from "lodash/sortedIndexBy" import sortedLastIndexBy from "lodash/sortedLastIndexBy" import type { ParserOptions } from "../common/parser-options" +import { isSFCFile } from "../common/parser-options" import type { ESLintExpression, Reference, @@ -39,6 +40,17 @@ const shorthandSign = /^[.:@#]/u const shorthandNameMap = { ":": "bind", ".": "bind", "@": "on", "#": "slot" } const invalidDynamicArgumentNextChar = /^[\s\r\n=/>]$/u +/** + * Gets the tag name from the given node or token. + * For SFC, it returns the value of `rawName` to be case sensitive. + */ +function getTagName( + startTagOrElement: { name: string; rawName: string }, + isSFC: boolean, +) { + return isSFC ? startTagOrElement.rawName : startTagOrElement.name +} + /** * Get the belonging document of the given node. * @param leafNode The node to get. @@ -694,7 +706,7 @@ export function convertToDirective( parserOptions, locationCalculator, node.value, - node.parent.parent.name, + getTagName(node.parent.parent, isSFCFile(parserOptions)), directive.key, ) diff --git a/test/fixtures/ast/address-component/ast.json b/test/fixtures/ast/address-component/ast.json new file mode 100644 index 00000000..7a2e1259 --- /dev/null +++ b/test/fixtures/ast/address-component/ast.json @@ -0,0 +1,995 @@ +{ + "type": "Program", + "start": 0, + "end": 0, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 0 + } + }, + "range": [ + 0, + 0 + ], + "body": [], + "sourceType": "script", + "comments": [], + "tokens": [], + "templateBody": { + "type": "VElement", + "range": [ + 0, + 151 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 9, + "column": 11 + } + }, + "name": "template", + "rawName": "template", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 0, + 10 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "selfClosing": false, + "attributes": [] + }, + "children": [ + { + "type": "VText", + "range": [ + 10, + 13 + ], + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 2, + "column": 2 + } + }, + "value": "\n " + }, + { + "type": "VElement", + "range": [ + 13, + 139 + ], + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 8, + "column": 8 + } + }, + "name": "div", + "rawName": "div", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 13, + 18 + ], + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 7 + } + }, + "selfClosing": false, + "attributes": [] + }, + "children": [ + { + "type": "VText", + "range": [ + 18, + 23 + ], + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 3, + "column": 4 + } + }, + "value": "\n " + }, + { + "type": "VElement", + "range": [ + 23, + 130 + ], + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 7, + "column": 8 + } + }, + "name": "p", + "rawName": "p", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 23, + 26 + ], + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 7 + } + }, + "selfClosing": false, + "attributes": [] + }, + "children": [ + { + "type": "VText", + "range": [ + 26, + 33 + ], + "loc": { + "start": { + "line": 3, + "column": 7 + }, + "end": { + "line": 4, + "column": 6 + } + }, + "value": "\n " + }, + { + "type": "VElement", + "range": [ + 33, + 121 + ], + "loc": { + "start": { + "line": 4, + "column": 6 + }, + "end": { + "line": 6, + "column": 62 + } + }, + "name": "address", + "rawName": "Address", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 33, + 121 + ], + "loc": { + "start": { + "line": 4, + "column": 6 + }, + "end": { + "line": 6, + "column": 62 + } + }, + "selfClosing": true, + "attributes": [ + { + "type": "VAttribute", + "range": [ + 50, + 58 + ], + "loc": { + "start": { + "line": 5, + "column": 8 + }, + "end": { + "line": 5, + "column": 16 + } + }, + "directive": false, + "key": { + "type": "VIdentifier", + "range": [ + 50, + 55 + ], + "loc": { + "start": { + "line": 5, + "column": 8 + }, + "end": { + "line": 5, + "column": 13 + } + }, + "name": "value", + "rawName": "value" + }, + "value": { + "type": "VLiteral", + "range": [ + 56, + 58 + ], + "loc": { + "start": { + "line": 5, + "column": 14 + }, + "end": { + "line": 5, + "column": 16 + } + }, + "value": "" + } + }, + { + "type": "VAttribute", + "range": [ + 67, + 119 + ], + "loc": { + "start": { + "line": 6, + "column": 8 + }, + "end": { + "line": 6, + "column": 60 + } + }, + "directive": false, + "key": { + "type": "VIdentifier", + "range": [ + 67, + 75 + ], + "loc": { + "start": { + "line": 6, + "column": 8 + }, + "end": { + "line": 6, + "column": 16 + } + }, + "name": "onchange", + "rawName": "onchange" + }, + "value": { + "type": "VLiteral", + "range": [ + 76, + 119 + ], + "loc": { + "start": { + "line": 6, + "column": 17 + }, + "end": { + "line": 6, + "column": 60 + } + }, + "value": "await setTokenAddress(event.target.value)" + } + } + ] + }, + "children": [], + "endTag": null, + "variables": [] + }, + { + "type": "VText", + "range": [ + 121, + 126 + ], + "loc": { + "start": { + "line": 6, + "column": 62 + }, + "end": { + "line": 7, + "column": 4 + } + }, + "value": "\n " + } + ], + "endTag": { + "type": "VEndTag", + "range": [ + 126, + 130 + ], + "loc": { + "start": { + "line": 7, + "column": 4 + }, + "end": { + "line": 7, + "column": 8 + } + } + }, + "variables": [] + }, + { + "type": "VText", + "range": [ + 130, + 133 + ], + "loc": { + "start": { + "line": 7, + "column": 8 + }, + "end": { + "line": 8, + "column": 2 + } + }, + "value": "\n " + } + ], + "endTag": { + "type": "VEndTag", + "range": [ + 133, + 139 + ], + "loc": { + "start": { + "line": 8, + "column": 2 + }, + "end": { + "line": 8, + "column": 8 + } + } + }, + "variables": [] + }, + { + "type": "VText", + "range": [ + 139, + 140 + ], + "loc": { + "start": { + "line": 8, + "column": 8 + }, + "end": { + "line": 9, + "column": 0 + } + }, + "value": "\n" + } + ], + "endTag": { + "type": "VEndTag", + "range": [ + 140, + 151 + ], + "loc": { + "start": { + "line": 9, + "column": 0 + }, + "end": { + "line": 9, + "column": 11 + } + } + }, + "variables": [], + "tokens": [ + { + "type": "HTMLTagOpen", + "range": [ + 0, + 9 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 9, + 10 + ], + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 10, + 13 + ], + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 2, + "column": 2 + } + }, + "value": "\n " + }, + { + "type": "HTMLTagOpen", + "range": [ + 13, + 17 + ], + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 6 + } + }, + "value": "div" + }, + { + "type": "HTMLTagClose", + "range": [ + 17, + 18 + ], + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 7 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 18, + 23 + ], + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 3, + "column": 4 + } + }, + "value": "\n " + }, + { + "type": "HTMLTagOpen", + "range": [ + 23, + 25 + ], + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 6 + } + }, + "value": "p" + }, + { + "type": "HTMLTagClose", + "range": [ + 25, + 26 + ], + "loc": { + "start": { + "line": 3, + "column": 6 + }, + "end": { + "line": 3, + "column": 7 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 26, + 33 + ], + "loc": { + "start": { + "line": 3, + "column": 7 + }, + "end": { + "line": 4, + "column": 6 + } + }, + "value": "\n " + }, + { + "type": "HTMLTagOpen", + "range": [ + 33, + 41 + ], + "loc": { + "start": { + "line": 4, + "column": 6 + }, + "end": { + "line": 4, + "column": 14 + } + }, + "value": "address" + }, + { + "type": "HTMLIdentifier", + "range": [ + 50, + 55 + ], + "loc": { + "start": { + "line": 5, + "column": 8 + }, + "end": { + "line": 5, + "column": 13 + } + }, + "value": "value" + }, + { + "type": "HTMLAssociation", + "range": [ + 55, + 56 + ], + "loc": { + "start": { + "line": 5, + "column": 13 + }, + "end": { + "line": 5, + "column": 14 + } + }, + "value": "" + }, + { + "type": "HTMLLiteral", + "range": [ + 56, + 58 + ], + "loc": { + "start": { + "line": 5, + "column": 14 + }, + "end": { + "line": 5, + "column": 16 + } + }, + "value": "" + }, + { + "type": "HTMLIdentifier", + "range": [ + 67, + 75 + ], + "loc": { + "start": { + "line": 6, + "column": 8 + }, + "end": { + "line": 6, + "column": 16 + } + }, + "value": "onchange" + }, + { + "type": "HTMLAssociation", + "range": [ + 75, + 76 + ], + "loc": { + "start": { + "line": 6, + "column": 16 + }, + "end": { + "line": 6, + "column": 17 + } + }, + "value": "" + }, + { + "type": "HTMLLiteral", + "range": [ + 76, + 119 + ], + "loc": { + "start": { + "line": 6, + "column": 17 + }, + "end": { + "line": 6, + "column": 60 + } + }, + "value": "await setTokenAddress(event.target.value)" + }, + { + "type": "HTMLSelfClosingTagClose", + "range": [ + 119, + 121 + ], + "loc": { + "start": { + "line": 6, + "column": 60 + }, + "end": { + "line": 6, + "column": 62 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 121, + 126 + ], + "loc": { + "start": { + "line": 6, + "column": 62 + }, + "end": { + "line": 7, + "column": 4 + } + }, + "value": "\n " + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 126, + 129 + ], + "loc": { + "start": { + "line": 7, + "column": 4 + }, + "end": { + "line": 7, + "column": 7 + } + }, + "value": "p" + }, + { + "type": "HTMLTagClose", + "range": [ + 129, + 130 + ], + "loc": { + "start": { + "line": 7, + "column": 7 + }, + "end": { + "line": 7, + "column": 8 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 130, + 133 + ], + "loc": { + "start": { + "line": 7, + "column": 8 + }, + "end": { + "line": 8, + "column": 2 + } + }, + "value": "\n " + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 133, + 138 + ], + "loc": { + "start": { + "line": 8, + "column": 2 + }, + "end": { + "line": 8, + "column": 7 + } + }, + "value": "div" + }, + { + "type": "HTMLTagClose", + "range": [ + 138, + 139 + ], + "loc": { + "start": { + "line": 8, + "column": 7 + }, + "end": { + "line": 8, + "column": 8 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 139, + 140 + ], + "loc": { + "start": { + "line": 8, + "column": 8 + }, + "end": { + "line": 9, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 140, + 150 + ], + "loc": { + "start": { + "line": 9, + "column": 0 + }, + "end": { + "line": 9, + "column": 10 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 150, + 151 + ], + "loc": { + "start": { + "line": 9, + "column": 10 + }, + "end": { + "line": 9, + "column": 11 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 151, + 152 + ], + "loc": { + "start": { + "line": 9, + "column": 11 + }, + "end": { + "line": 10, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLWhitespace", + "range": [ + 220, + 221 + ], + "loc": { + "start": { + "line": 10, + "column": 68 + }, + "end": { + "line": 11, + "column": 0 + } + }, + "value": "\n" + } + ], + "comments": [ + { + "type": "HTMLComment", + "range": [ + 152, + 220 + ], + "loc": { + "start": { + "line": 10, + "column": 0 + }, + "end": { + "line": 10, + "column": 68 + } + }, + "value": " from https://github.com/vuejs/eslint-plugin-vue/issues/1403 " + } + ], + "errors": [ + { + "message": "non-void-html-element-start-tag-with-trailing-solidus", + "index": 33, + "lineNumber": 4, + "column": 6 + } + ] + } +} \ No newline at end of file diff --git a/test/fixtures/ast/address-component/source.vue b/test/fixtures/ast/address-component/source.vue new file mode 100644 index 00000000..f8d10f1a --- /dev/null +++ b/test/fixtures/ast/address-component/source.vue @@ -0,0 +1,10 @@ + + diff --git a/test/fixtures/ast/address-component/token-ranges.json b/test/fixtures/ast/address-component/token-ranges.json new file mode 100644 index 00000000..3dc8108b --- /dev/null +++ b/test/fixtures/ast/address-component/token-ranges.json @@ -0,0 +1,31 @@ +[ + "", + "\n ", + "", + "\n ", + "", + "\n ", + "", + "\n ", + "", + "\n ", + "", + "\n", + "", + "\n", + "\n", + "" +] \ No newline at end of file diff --git a/test/fixtures/ast/address-component/tree.json b/test/fixtures/ast/address-component/tree.json new file mode 100644 index 00000000..0a68820f --- /dev/null +++ b/test/fixtures/ast/address-component/tree.json @@ -0,0 +1,124 @@ +[ + { + "type": "VElement", + "text": "", + "children": [ + { + "type": "VStartTag", + "text": "", + "children": [] + } + ] + } +] \ No newline at end of file diff --git a/test/fixtures/ast/cdata/ast.json b/test/fixtures/ast/cdata/ast.json index 6c79e095..9e6cfa76 100644 --- a/test/fixtures/ast/cdata/ast.json +++ b/test/fixtures/ast/cdata/ast.json @@ -94,7 +94,7 @@ } }, "name": "svg", - "rawName": "SVG", + "rawName": "svg", "namespace": "http://www.w3.org/2000/svg", "startTag": { "type": "VStartTag", diff --git a/test/fixtures/ast/cdata/source.vue b/test/fixtures/ast/cdata/source.vue index ca62aec3..61af1d18 100644 --- a/test/fixtures/ast/cdata/source.vue +++ b/test/fixtures/ast/cdata/source.vue @@ -1,5 +1,5 @@ ", + "text": "", "children": [ { "type": "VStartTag", @@ -15,11 +15,11 @@ }, { "type": "VElement", - "text": "\n \n \n ", + "text": "\n \n \n ", "children": [ { "type": "VStartTag", - "text": "", + "text": "", "children": [ { "type": "VAttribute", diff --git a/test/fixtures/ast/foreignobject-lower/ast.json b/test/fixtures/ast/foreignobject-lower/ast.json new file mode 100644 index 00000000..a0633d60 --- /dev/null +++ b/test/fixtures/ast/foreignobject-lower/ast.json @@ -0,0 +1,618 @@ +{ + "type": "Program", + "start": 0, + "end": 0, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 0 + } + }, + "range": [ + 0, + 0 + ], + "body": [], + "sourceType": "script", + "comments": [], + "tokens": [], + "templateBody": { + "type": "VElement", + "range": [ + 0, + 92 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 6, + "column": 11 + } + }, + "name": "template", + "rawName": "template", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 0, + 10 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "selfClosing": false, + "attributes": [] + }, + "children": [ + { + "type": "VText", + "range": [ + 10, + 15 + ], + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 2, + "column": 4 + } + }, + "value": "\n " + }, + { + "type": "VElement", + "range": [ + 15, + 80 + ], + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 5, + "column": 10 + } + }, + "name": "svg", + "rawName": "svg", + "namespace": "http://www.w3.org/2000/svg", + "startTag": { + "type": "VStartTag", + "range": [ + 15, + 20 + ], + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 9 + } + }, + "selfClosing": false, + "attributes": [] + }, + "children": [ + { + "type": "VText", + "range": [ + 20, + 29 + ], + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 3, + "column": 8 + } + }, + "value": "\n " + }, + { + "type": "VElement", + "range": [ + 29, + 69 + ], + "loc": { + "start": { + "line": 3, + "column": 8 + }, + "end": { + "line": 4, + "column": 24 + } + }, + "name": "foreignObject", + "rawName": "foreignobject", + "namespace": "http://www.w3.org/2000/svg", + "startTag": { + "type": "VStartTag", + "range": [ + 29, + 44 + ], + "loc": { + "start": { + "line": 3, + "column": 8 + }, + "end": { + "line": 3, + "column": 23 + } + }, + "selfClosing": false, + "attributes": [] + }, + "children": [ + { + "type": "VText", + "range": [ + 44, + 53 + ], + "loc": { + "start": { + "line": 3, + "column": 23 + }, + "end": { + "line": 4, + "column": 8 + } + }, + "value": "\n " + } + ], + "endTag": { + "type": "VEndTag", + "range": [ + 53, + 69 + ], + "loc": { + "start": { + "line": 4, + "column": 8 + }, + "end": { + "line": 4, + "column": 24 + } + } + }, + "variables": [] + }, + { + "type": "VText", + "range": [ + 69, + 74 + ], + "loc": { + "start": { + "line": 4, + "column": 24 + }, + "end": { + "line": 5, + "column": 4 + } + }, + "value": "\n " + } + ], + "endTag": { + "type": "VEndTag", + "range": [ + 74, + 80 + ], + "loc": { + "start": { + "line": 5, + "column": 4 + }, + "end": { + "line": 5, + "column": 10 + } + } + }, + "variables": [] + }, + { + "type": "VText", + "range": [ + 80, + 81 + ], + "loc": { + "start": { + "line": 5, + "column": 10 + }, + "end": { + "line": 6, + "column": 0 + } + }, + "value": "\n" + } + ], + "endTag": { + "type": "VEndTag", + "range": [ + 81, + 92 + ], + "loc": { + "start": { + "line": 6, + "column": 0 + }, + "end": { + "line": 6, + "column": 11 + } + } + }, + "variables": [], + "tokens": [ + { + "type": "HTMLTagOpen", + "range": [ + 0, + 9 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 9, + 10 + ], + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 10, + 15 + ], + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 2, + "column": 4 + } + }, + "value": "\n " + }, + { + "type": "HTMLTagOpen", + "range": [ + 15, + 19 + ], + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 8 + } + }, + "value": "svg" + }, + { + "type": "HTMLTagClose", + "range": [ + 19, + 20 + ], + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 9 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 20, + 29 + ], + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 3, + "column": 8 + } + }, + "value": "\n " + }, + { + "type": "HTMLTagOpen", + "range": [ + 29, + 43 + ], + "loc": { + "start": { + "line": 3, + "column": 8 + }, + "end": { + "line": 3, + "column": 22 + } + }, + "value": "foreignobject" + }, + { + "type": "HTMLTagClose", + "range": [ + 43, + 44 + ], + "loc": { + "start": { + "line": 3, + "column": 22 + }, + "end": { + "line": 3, + "column": 23 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 44, + 53 + ], + "loc": { + "start": { + "line": 3, + "column": 23 + }, + "end": { + "line": 4, + "column": 8 + } + }, + "value": "\n " + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 53, + 68 + ], + "loc": { + "start": { + "line": 4, + "column": 8 + }, + "end": { + "line": 4, + "column": 23 + } + }, + "value": "foreignobject" + }, + { + "type": "HTMLTagClose", + "range": [ + 68, + 69 + ], + "loc": { + "start": { + "line": 4, + "column": 23 + }, + "end": { + "line": 4, + "column": 24 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 69, + 74 + ], + "loc": { + "start": { + "line": 4, + "column": 24 + }, + "end": { + "line": 5, + "column": 4 + } + }, + "value": "\n " + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 74, + 79 + ], + "loc": { + "start": { + "line": 5, + "column": 4 + }, + "end": { + "line": 5, + "column": 9 + } + }, + "value": "svg" + }, + { + "type": "HTMLTagClose", + "range": [ + 79, + 80 + ], + "loc": { + "start": { + "line": 5, + "column": 9 + }, + "end": { + "line": 5, + "column": 10 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 80, + 81 + ], + "loc": { + "start": { + "line": 5, + "column": 10 + }, + "end": { + "line": 6, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 81, + 91 + ], + "loc": { + "start": { + "line": 6, + "column": 0 + }, + "end": { + "line": 6, + "column": 10 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 91, + 92 + ], + "loc": { + "start": { + "line": 6, + "column": 10 + }, + "end": { + "line": 6, + "column": 11 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 92, + 93 + ], + "loc": { + "start": { + "line": 6, + "column": 11 + }, + "end": { + "line": 7, + "column": 0 + } + }, + "value": "\n" + } + ], + "comments": [], + "errors": [] + } +} \ No newline at end of file diff --git a/test/fixtures/ast/foreignobject-lower/source.vue b/test/fixtures/ast/foreignobject-lower/source.vue new file mode 100644 index 00000000..60c36533 --- /dev/null +++ b/test/fixtures/ast/foreignobject-lower/source.vue @@ -0,0 +1,6 @@ + diff --git a/test/fixtures/ast/foreignobject-lower/token-ranges.json b/test/fixtures/ast/foreignobject-lower/token-ranges.json new file mode 100644 index 00000000..6c369be4 --- /dev/null +++ b/test/fixtures/ast/foreignobject-lower/token-ranges.json @@ -0,0 +1,20 @@ +[ + "", + "\n ", + "", + "\n ", + "", + "\n ", + "", + "\n ", + "", + "\n", + "", + "\n" +] \ No newline at end of file diff --git a/test/fixtures/ast/foreignobject-lower/tree.json b/test/fixtures/ast/foreignobject-lower/tree.json new file mode 100644 index 00000000..991839f9 --- /dev/null +++ b/test/fixtures/ast/foreignobject-lower/tree.json @@ -0,0 +1,75 @@ +[ + { + "type": "VElement", + "text": "", + "children": [ + { + "type": "VStartTag", + "text": "", + "children": [] + } + ] + } +] \ No newline at end of file diff --git a/test/fixtures/ast/foreignobject/ast.json b/test/fixtures/ast/foreignobject/ast.json index fb4942f8..b1e10d56 100644 --- a/test/fixtures/ast/foreignobject/ast.json +++ b/test/fixtures/ast/foreignobject/ast.json @@ -267,7 +267,7 @@ } }, "name": "foreignObject", - "rawName": "foreignobject", + "rawName": "foreignObject", "namespace": "http://www.w3.org/2000/svg", "startTag": { "type": "VStartTag", diff --git a/test/fixtures/ast/foreignobject/source.vue b/test/fixtures/ast/foreignobject/source.vue index b8e86b43..5c41fe86 100644 --- a/test/fixtures/ast/foreignobject/source.vue +++ b/test/fixtures/ast/foreignobject/source.vue @@ -1,8 +1,8 @@ diff --git a/test/fixtures/ast/foreignobject/token-ranges.json b/test/fixtures/ast/foreignobject/token-ranges.json index 39743b51..3b3c3eca 100644 --- a/test/fixtures/ast/foreignobject/token-ranges.json +++ b/test/fixtures/ast/foreignobject/token-ranges.json @@ -11,7 +11,7 @@ "\"\"", "/>", "\n ", - "", "\n ", "", "\n ", - "", "\n ", "\n \n \n \n
Hello
\n
\n
\n", + "text": "", "children": [ { "type": "VStartTag", @@ -15,7 +15,7 @@ }, { "type": "VElement", - "text": "\n \n \n
Hello
\n
\n
", + "text": "\n \n \n
Hello
\n
\n
", "children": [ { "type": "VStartTag", @@ -62,11 +62,11 @@ }, { "type": "VElement", - "text": "\n
Hello
\n
", + "text": "\n
Hello
\n
", "children": [ { "type": "VStartTag", - "text": "", + "text": "", "children": [] }, { @@ -102,7 +102,7 @@ }, { "type": "VEndTag", - "text": "", + "text": "", "children": [] } ] diff --git a/test/fixtures/ast/input-component/ast.json b/test/fixtures/ast/input-component/ast.json new file mode 100644 index 00000000..422c77da --- /dev/null +++ b/test/fixtures/ast/input-component/ast.json @@ -0,0 +1,1246 @@ +{ + "type": "Program", + "start": 0, + "end": 0, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 0 + } + }, + "range": [ + 0, + 0 + ], + "body": [], + "sourceType": "script", + "comments": [], + "tokens": [], + "templateBody": { + "type": "VElement", + "range": [ + 0, + 141 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 9, + "column": 11 + } + }, + "name": "template", + "rawName": "template", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 0, + 10 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "selfClosing": false, + "attributes": [] + }, + "children": [ + { + "type": "VText", + "range": [ + 10, + 13 + ], + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 2, + "column": 2 + } + }, + "value": "\n " + }, + { + "type": "VElement", + "range": [ + 13, + 129 + ], + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 8, + "column": 8 + } + }, + "name": "div", + "rawName": "div", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 13, + 18 + ], + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 7 + } + }, + "selfClosing": false, + "attributes": [] + }, + "children": [ + { + "type": "VText", + "range": [ + 18, + 23 + ], + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 3, + "column": 4 + } + }, + "value": "\n " + }, + { + "type": "VElement", + "range": [ + 23, + 120 + ], + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 7, + "column": 12 + } + }, + "name": "input", + "rawName": "Input", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 23, + 30 + ], + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 11 + } + }, + "selfClosing": false, + "attributes": [] + }, + "children": [ + { + "type": "VText", + "range": [ + 30, + 37 + ], + "loc": { + "start": { + "line": 3, + "column": 11 + }, + "end": { + "line": 4, + "column": 6 + } + }, + "value": "\n " + }, + { + "type": "VElement", + "range": [ + 37, + 107 + ], + "loc": { + "start": { + "line": 4, + "column": 6 + }, + "end": { + "line": 6, + "column": 17 + } + }, + "name": "template", + "rawName": "template", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 37, + 55 + ], + "loc": { + "start": { + "line": 4, + "column": 6 + }, + "end": { + "line": 4, + "column": 24 + } + }, + "selfClosing": false, + "attributes": [ + { + "type": "VAttribute", + "range": [ + 47, + 54 + ], + "loc": { + "start": { + "line": 4, + "column": 16 + }, + "end": { + "line": 4, + "column": 23 + } + }, + "directive": true, + "key": { + "type": "VDirectiveKey", + "range": [ + 47, + 54 + ], + "loc": { + "start": { + "line": 4, + "column": 16 + }, + "end": { + "line": 4, + "column": 23 + } + }, + "name": { + "type": "VIdentifier", + "range": [ + 47, + 48 + ], + "loc": { + "start": { + "column": 16, + "line": 4 + }, + "end": { + "column": 17, + "line": 4 + } + }, + "name": "slot", + "rawName": "#" + }, + "argument": { + "type": "VIdentifier", + "range": [ + 48, + 54 + ], + "loc": { + "start": { + "column": 17, + "line": 4 + }, + "end": { + "column": 23, + "line": 4 + } + }, + "name": "suffix", + "rawName": "suffix" + }, + "modifiers": [] + }, + "value": null + } + ] + }, + "children": [ + { + "type": "VText", + "range": [ + 55, + 64 + ], + "loc": { + "start": { + "line": 4, + "column": 24 + }, + "end": { + "line": 5, + "column": 8 + } + }, + "value": "\n " + }, + { + "type": "VElement", + "range": [ + 64, + 89 + ], + "loc": { + "start": { + "line": 5, + "column": 8 + }, + "end": { + "line": 5, + "column": 33 + } + }, + "name": "icon", + "rawName": "Icon", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 64, + 82 + ], + "loc": { + "start": { + "line": 5, + "column": 8 + }, + "end": { + "line": 5, + "column": 26 + } + }, + "selfClosing": false, + "attributes": [ + { + "type": "VAttribute", + "range": [ + 70, + 81 + ], + "loc": { + "start": { + "line": 5, + "column": 14 + }, + "end": { + "line": 5, + "column": 25 + } + }, + "directive": false, + "key": { + "type": "VIdentifier", + "range": [ + 70, + 74 + ], + "loc": { + "start": { + "line": 5, + "column": 14 + }, + "end": { + "line": 5, + "column": 18 + } + }, + "name": "name", + "rawName": "name" + }, + "value": { + "type": "VLiteral", + "range": [ + 75, + 81 + ], + "loc": { + "start": { + "line": 5, + "column": 19 + }, + "end": { + "line": 5, + "column": 25 + } + }, + "value": "user" + } + } + ] + }, + "children": [], + "endTag": { + "type": "VEndTag", + "range": [ + 82, + 89 + ], + "loc": { + "start": { + "line": 5, + "column": 26 + }, + "end": { + "line": 5, + "column": 33 + } + } + }, + "variables": [] + }, + { + "type": "VText", + "range": [ + 89, + 96 + ], + "loc": { + "start": { + "line": 5, + "column": 33 + }, + "end": { + "line": 6, + "column": 6 + } + }, + "value": "\n " + } + ], + "endTag": { + "type": "VEndTag", + "range": [ + 96, + 107 + ], + "loc": { + "start": { + "line": 6, + "column": 6 + }, + "end": { + "line": 6, + "column": 17 + } + } + }, + "variables": [] + }, + { + "type": "VText", + "range": [ + 107, + 112 + ], + "loc": { + "start": { + "line": 6, + "column": 17 + }, + "end": { + "line": 7, + "column": 4 + } + }, + "value": "\n " + } + ], + "endTag": { + "type": "VEndTag", + "range": [ + 112, + 120 + ], + "loc": { + "start": { + "line": 7, + "column": 4 + }, + "end": { + "line": 7, + "column": 12 + } + } + }, + "variables": [] + }, + { + "type": "VText", + "range": [ + 120, + 123 + ], + "loc": { + "start": { + "line": 7, + "column": 12 + }, + "end": { + "line": 8, + "column": 2 + } + }, + "value": "\n " + } + ], + "endTag": { + "type": "VEndTag", + "range": [ + 123, + 129 + ], + "loc": { + "start": { + "line": 8, + "column": 2 + }, + "end": { + "line": 8, + "column": 8 + } + } + }, + "variables": [] + }, + { + "type": "VText", + "range": [ + 129, + 130 + ], + "loc": { + "start": { + "line": 8, + "column": 8 + }, + "end": { + "line": 9, + "column": 0 + } + }, + "value": "\n" + } + ], + "endTag": { + "type": "VEndTag", + "range": [ + 130, + 141 + ], + "loc": { + "start": { + "line": 9, + "column": 0 + }, + "end": { + "line": 9, + "column": 11 + } + } + }, + "variables": [], + "tokens": [ + { + "type": "HTMLTagOpen", + "range": [ + 0, + 9 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 9, + 10 + ], + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 10, + 13 + ], + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 2, + "column": 2 + } + }, + "value": "\n " + }, + { + "type": "HTMLTagOpen", + "range": [ + 13, + 17 + ], + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 6 + } + }, + "value": "div" + }, + { + "type": "HTMLTagClose", + "range": [ + 17, + 18 + ], + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 2, + "column": 7 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 18, + 23 + ], + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 3, + "column": 4 + } + }, + "value": "\n " + }, + { + "type": "HTMLTagOpen", + "range": [ + 23, + 29 + ], + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 10 + } + }, + "value": "input" + }, + { + "type": "HTMLTagClose", + "range": [ + 29, + 30 + ], + "loc": { + "start": { + "line": 3, + "column": 10 + }, + "end": { + "line": 3, + "column": 11 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 30, + 37 + ], + "loc": { + "start": { + "line": 3, + "column": 11 + }, + "end": { + "line": 4, + "column": 6 + } + }, + "value": "\n " + }, + { + "type": "HTMLTagOpen", + "range": [ + 37, + 46 + ], + "loc": { + "start": { + "line": 4, + "column": 6 + }, + "end": { + "line": 4, + "column": 15 + } + }, + "value": "template" + }, + { + "type": "Punctuator", + "range": [ + 47, + 48 + ], + "loc": { + "start": { + "column": 16, + "line": 4 + }, + "end": { + "column": 17, + "line": 4 + } + }, + "value": "#" + }, + { + "type": "HTMLIdentifier", + "range": [ + 48, + 54 + ], + "loc": { + "start": { + "column": 17, + "line": 4 + }, + "end": { + "column": 23, + "line": 4 + } + }, + "value": "suffix" + }, + { + "type": "HTMLTagClose", + "range": [ + 54, + 55 + ], + "loc": { + "start": { + "line": 4, + "column": 23 + }, + "end": { + "line": 4, + "column": 24 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 55, + 64 + ], + "loc": { + "start": { + "line": 4, + "column": 24 + }, + "end": { + "line": 5, + "column": 8 + } + }, + "value": "\n " + }, + { + "type": "HTMLTagOpen", + "range": [ + 64, + 69 + ], + "loc": { + "start": { + "line": 5, + "column": 8 + }, + "end": { + "line": 5, + "column": 13 + } + }, + "value": "icon" + }, + { + "type": "HTMLIdentifier", + "range": [ + 70, + 74 + ], + "loc": { + "start": { + "line": 5, + "column": 14 + }, + "end": { + "line": 5, + "column": 18 + } + }, + "value": "name" + }, + { + "type": "HTMLAssociation", + "range": [ + 74, + 75 + ], + "loc": { + "start": { + "line": 5, + "column": 18 + }, + "end": { + "line": 5, + "column": 19 + } + }, + "value": "" + }, + { + "type": "HTMLLiteral", + "range": [ + 75, + 81 + ], + "loc": { + "start": { + "line": 5, + "column": 19 + }, + "end": { + "line": 5, + "column": 25 + } + }, + "value": "user" + }, + { + "type": "HTMLTagClose", + "range": [ + 81, + 82 + ], + "loc": { + "start": { + "line": 5, + "column": 25 + }, + "end": { + "line": 5, + "column": 26 + } + }, + "value": "" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 82, + 88 + ], + "loc": { + "start": { + "line": 5, + "column": 26 + }, + "end": { + "line": 5, + "column": 32 + } + }, + "value": "icon" + }, + { + "type": "HTMLTagClose", + "range": [ + 88, + 89 + ], + "loc": { + "start": { + "line": 5, + "column": 32 + }, + "end": { + "line": 5, + "column": 33 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 89, + 96 + ], + "loc": { + "start": { + "line": 5, + "column": 33 + }, + "end": { + "line": 6, + "column": 6 + } + }, + "value": "\n " + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 96, + 106 + ], + "loc": { + "start": { + "line": 6, + "column": 6 + }, + "end": { + "line": 6, + "column": 16 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 106, + 107 + ], + "loc": { + "start": { + "line": 6, + "column": 16 + }, + "end": { + "line": 6, + "column": 17 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 107, + 112 + ], + "loc": { + "start": { + "line": 6, + "column": 17 + }, + "end": { + "line": 7, + "column": 4 + } + }, + "value": "\n " + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 112, + 119 + ], + "loc": { + "start": { + "line": 7, + "column": 4 + }, + "end": { + "line": 7, + "column": 11 + } + }, + "value": "input" + }, + { + "type": "HTMLTagClose", + "range": [ + 119, + 120 + ], + "loc": { + "start": { + "line": 7, + "column": 11 + }, + "end": { + "line": 7, + "column": 12 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 120, + 123 + ], + "loc": { + "start": { + "line": 7, + "column": 12 + }, + "end": { + "line": 8, + "column": 2 + } + }, + "value": "\n " + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 123, + 128 + ], + "loc": { + "start": { + "line": 8, + "column": 2 + }, + "end": { + "line": 8, + "column": 7 + } + }, + "value": "div" + }, + { + "type": "HTMLTagClose", + "range": [ + 128, + 129 + ], + "loc": { + "start": { + "line": 8, + "column": 7 + }, + "end": { + "line": 8, + "column": 8 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 129, + 130 + ], + "loc": { + "start": { + "line": 8, + "column": 8 + }, + "end": { + "line": 9, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 130, + 140 + ], + "loc": { + "start": { + "line": 9, + "column": 0 + }, + "end": { + "line": 9, + "column": 10 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 140, + 141 + ], + "loc": { + "start": { + "line": 9, + "column": 10 + }, + "end": { + "line": 9, + "column": 11 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 141, + 142 + ], + "loc": { + "start": { + "line": 9, + "column": 11 + }, + "end": { + "line": 10, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLWhitespace", + "range": [ + 210, + 211 + ], + "loc": { + "start": { + "line": 10, + "column": 68 + }, + "end": { + "line": 11, + "column": 0 + } + }, + "value": "\n" + } + ], + "comments": [ + { + "type": "HTMLComment", + "range": [ + 142, + 210 + ], + "loc": { + "start": { + "line": 10, + "column": 0 + }, + "end": { + "line": 10, + "column": 68 + } + }, + "value": " from https://github.com/vuejs/eslint-plugin-vue/issues/1292 " + } + ], + "errors": [] + } +} \ No newline at end of file diff --git a/test/fixtures/ast/input-component/source.vue b/test/fixtures/ast/input-component/source.vue new file mode 100644 index 00000000..be80913a --- /dev/null +++ b/test/fixtures/ast/input-component/source.vue @@ -0,0 +1,10 @@ +
+ + + +
+ + diff --git a/test/fixtures/ast/input-component/token-ranges.json b/test/fixtures/ast/input-component/token-ranges.json new file mode 100644 index 00000000..72ecce42 --- /dev/null +++ b/test/fixtures/ast/input-component/token-ranges.json @@ -0,0 +1,38 @@ +[ + "", + "\n ", + "", + "\n ", + "", + "\n ", + "", + "\n ", + "", + "", + "\n ", + "", + "\n ", + "", + "\n ", + "", + "\n", + "", + "\n", + "\n", + "" +] \ No newline at end of file diff --git a/test/fixtures/ast/input-component/tree.json b/test/fixtures/ast/input-component/tree.json new file mode 100644 index 00000000..859c2908 --- /dev/null +++ b/test/fixtures/ast/input-component/tree.json @@ -0,0 +1,162 @@ +[ + { + "type": "VElement", + "text": "", + "children": [ + { + "type": "VStartTag", + "text": "", + "children": [] + } + ] + } +] \ No newline at end of file diff --git a/test/fixtures/ast/link-component/ast.json b/test/fixtures/ast/link-component/ast.json new file mode 100644 index 00000000..fd6b6861 --- /dev/null +++ b/test/fixtures/ast/link-component/ast.json @@ -0,0 +1,2581 @@ +{ + "type": "Program", + "start": 0, + "end": 0, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 0 + } + }, + "range": [ + 0, + 0 + ], + "body": [], + "sourceType": "script", + "comments": [], + "tokens": [], + "templateBody": { + "type": "VElement", + "range": [ + 0, + 277 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 10, + "column": 11 + } + }, + "name": "template", + "rawName": "template", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 0, + 10 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "selfClosing": false, + "attributes": [] + }, + "children": [ + { + "type": "VText", + "range": [ + 10, + 13 + ], + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 2, + "column": 2 + } + }, + "value": "\n " + }, + { + "type": "VElement", + "range": [ + 13, + 265 + ], + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 9, + "column": 9 + } + }, + "name": "link", + "rawName": "Link", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 13, + 54 + ], + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 43 + } + }, + "selfClosing": false, + "attributes": [ + { + "type": "VAttribute", + "range": [ + 19, + 27 + ], + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 16 + } + }, + "directive": true, + "key": { + "type": "VDirectiveKey", + "range": [ + 19, + 22 + ], + "loc": { + "start": { + "line": 2, + "column": 8 + }, + "end": { + "line": 2, + "column": 11 + } + }, + "name": { + "type": "VIdentifier", + "range": [ + 19, + 20 + ], + "loc": { + "start": { + "column": 8, + "line": 2 + }, + "end": { + "column": 9, + "line": 2 + } + }, + "name": "bind", + "rawName": ":" + }, + "argument": { + "type": "VIdentifier", + "range": [ + 20, + 22 + ], + "loc": { + "start": { + "column": 9, + "line": 2 + }, + "end": { + "column": 11, + "line": 2 + } + }, + "name": "to", + "rawName": "to" + }, + "modifiers": [] + }, + "value": { + "type": "VExpressionContainer", + "range": [ + 23, + 27 + ], + "loc": { + "start": { + "line": 2, + "column": 12 + }, + "end": { + "line": 2, + "column": 16 + } + }, + "expression": { + "type": "Identifier", + "start": 24, + "end": 26, + "loc": { + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 2, + "column": 15 + } + }, + "range": [ + 24, + 26 + ], + "name": "to" + }, + "references": [ + { + "id": { + "type": "Identifier", + "start": 24, + "end": 26, + "loc": { + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 2, + "column": 15 + } + }, + "range": [ + 24, + 26 + ], + "name": "to" + }, + "mode": "r" + } + ] + } + }, + { + "type": "VAttribute", + "range": [ + 28, + 53 + ], + "loc": { + "start": { + "line": 2, + "column": 17 + }, + "end": { + "line": 2, + "column": 42 + } + }, + "directive": false, + "key": { + "type": "VIdentifier", + "range": [ + 28, + 33 + ], + "loc": { + "start": { + "line": 2, + "column": 17 + }, + "end": { + "line": 2, + "column": 22 + } + }, + "name": "class", + "rawName": "class" + }, + "value": { + "type": "VLiteral", + "range": [ + 34, + 53 + ], + "loc": { + "start": { + "line": 2, + "column": 23 + }, + "end": { + "line": 2, + "column": 42 + } + }, + "value": "flex items-center" + } + } + ] + }, + "children": [ + { + "type": "VText", + "range": [ + 54, + 59 + ], + "loc": { + "start": { + "line": 2, + "column": 43 + }, + "end": { + "line": 3, + "column": 4 + } + }, + "value": "\n " + }, + { + "type": "VElement", + "range": [ + 59, + 242 + ], + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 7, + "column": 11 + } + }, + "name": "span", + "rawName": "span", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 59, + 113 + ], + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 58 + } + }, + "selfClosing": false, + "attributes": [ + { + "type": "VAttribute", + "range": [ + 65, + 99 + ], + "loc": { + "start": { + "line": 3, + "column": 10 + }, + "end": { + "line": 3, + "column": 44 + } + }, + "directive": true, + "key": { + "type": "VDirectiveKey", + "range": [ + 65, + 69 + ], + "loc": { + "start": { + "line": 3, + "column": 10 + }, + "end": { + "line": 3, + "column": 14 + } + }, + "name": { + "type": "VIdentifier", + "range": [ + 65, + 69 + ], + "loc": { + "start": { + "column": 10, + "line": 3 + }, + "end": { + "column": 14, + "line": 3 + } + }, + "name": "if", + "rawName": "if" + }, + "argument": null, + "modifiers": [] + }, + "value": { + "type": "VExpressionContainer", + "range": [ + 70, + 99 + ], + "loc": { + "start": { + "line": 3, + "column": 15 + }, + "end": { + "line": 3, + "column": 44 + } + }, + "expression": { + "type": "LogicalExpression", + "start": 71, + "end": 98, + "loc": { + "start": { + "line": 3, + "column": 16 + }, + "end": { + "line": 3, + "column": 43 + } + }, + "range": [ + 71, + 98 + ], + "left": { + "type": "Identifier", + "start": 71, + "end": 81, + "loc": { + "start": { + "line": 3, + "column": 16 + }, + "end": { + "line": 3, + "column": 26 + } + }, + "range": [ + 71, + 81 + ], + "name": "prefixIcon" + }, + "operator": "||", + "right": { + "type": "MemberExpression", + "start": 85, + "end": 98, + "loc": { + "start": { + "line": 3, + "column": 30 + }, + "end": { + "line": 3, + "column": 43 + } + }, + "range": [ + 85, + 98 + ], + "object": { + "type": "Identifier", + "start": 85, + "end": 91, + "loc": { + "start": { + "line": 3, + "column": 30 + }, + "end": { + "line": 3, + "column": 36 + } + }, + "range": [ + 85, + 91 + ], + "name": "$slots" + }, + "property": { + "type": "Identifier", + "start": 92, + "end": 98, + "loc": { + "start": { + "line": 3, + "column": 37 + }, + "end": { + "line": 3, + "column": 43 + } + }, + "range": [ + 92, + 98 + ], + "name": "prefix" + }, + "computed": false + } + }, + "references": [ + { + "id": { + "type": "Identifier", + "start": 71, + "end": 81, + "loc": { + "start": { + "line": 3, + "column": 16 + }, + "end": { + "line": 3, + "column": 26 + } + }, + "range": [ + 71, + 81 + ], + "name": "prefixIcon" + }, + "mode": "r" + }, + { + "id": { + "type": "Identifier", + "start": 85, + "end": 91, + "loc": { + "start": { + "line": 3, + "column": 30 + }, + "end": { + "line": 3, + "column": 36 + } + }, + "range": [ + 85, + 91 + ], + "name": "$slots" + }, + "mode": "r" + } + ] + } + }, + { + "type": "VAttribute", + "range": [ + 100, + 112 + ], + "loc": { + "start": { + "line": 3, + "column": 45 + }, + "end": { + "line": 3, + "column": 57 + } + }, + "directive": false, + "key": { + "type": "VIdentifier", + "range": [ + 100, + 105 + ], + "loc": { + "start": { + "line": 3, + "column": 45 + }, + "end": { + "line": 3, + "column": 50 + } + }, + "name": "class", + "rawName": "class" + }, + "value": { + "type": "VLiteral", + "range": [ + 106, + 112 + ], + "loc": { + "start": { + "line": 3, + "column": 51 + }, + "end": { + "line": 3, + "column": 57 + } + }, + "value": "mr-1" + } + } + ] + }, + "children": [ + { + "type": "VText", + "range": [ + 113, + 120 + ], + "loc": { + "start": { + "line": 3, + "column": 58 + }, + "end": { + "line": 4, + "column": 6 + } + }, + "value": "\n " + }, + { + "type": "VElement", + "range": [ + 120, + 230 + ], + "loc": { + "start": { + "line": 4, + "column": 6 + }, + "end": { + "line": 6, + "column": 13 + } + }, + "name": "slot", + "rawName": "slot", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 120, + 140 + ], + "loc": { + "start": { + "line": 4, + "column": 6 + }, + "end": { + "line": 4, + "column": 26 + } + }, + "selfClosing": false, + "attributes": [ + { + "type": "VAttribute", + "range": [ + 126, + 139 + ], + "loc": { + "start": { + "line": 4, + "column": 12 + }, + "end": { + "line": 4, + "column": 25 + } + }, + "directive": false, + "key": { + "type": "VIdentifier", + "range": [ + 126, + 130 + ], + "loc": { + "start": { + "line": 4, + "column": 12 + }, + "end": { + "line": 4, + "column": 16 + } + }, + "name": "name", + "rawName": "name" + }, + "value": { + "type": "VLiteral", + "range": [ + 131, + 139 + ], + "loc": { + "start": { + "line": 4, + "column": 17 + }, + "end": { + "line": 4, + "column": 25 + } + }, + "value": "prefix" + } + } + ] + }, + "children": [ + { + "type": "VText", + "range": [ + 140, + 149 + ], + "loc": { + "start": { + "line": 4, + "column": 26 + }, + "end": { + "line": 5, + "column": 8 + } + }, + "value": "\n " + }, + { + "type": "VElement", + "range": [ + 149, + 216 + ], + "loc": { + "start": { + "line": 5, + "column": 8 + }, + "end": { + "line": 5, + "column": 75 + } + }, + "name": "fontawesomeicon", + "rawName": "FontAwesomeIcon", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 149, + 216 + ], + "loc": { + "start": { + "line": 5, + "column": 8 + }, + "end": { + "line": 5, + "column": 75 + } + }, + "selfClosing": true, + "attributes": [ + { + "type": "VAttribute", + "range": [ + 166, + 183 + ], + "loc": { + "start": { + "line": 5, + "column": 25 + }, + "end": { + "line": 5, + "column": 42 + } + }, + "directive": true, + "key": { + "type": "VDirectiveKey", + "range": [ + 166, + 170 + ], + "loc": { + "start": { + "line": 5, + "column": 25 + }, + "end": { + "line": 5, + "column": 29 + } + }, + "name": { + "type": "VIdentifier", + "range": [ + 166, + 170 + ], + "loc": { + "start": { + "column": 25, + "line": 5 + }, + "end": { + "column": 29, + "line": 5 + } + }, + "name": "if", + "rawName": "if" + }, + "argument": null, + "modifiers": [] + }, + "value": { + "type": "VExpressionContainer", + "range": [ + 171, + 183 + ], + "loc": { + "start": { + "line": 5, + "column": 30 + }, + "end": { + "line": 5, + "column": 42 + } + }, + "expression": { + "type": "Identifier", + "start": 172, + "end": 182, + "loc": { + "start": { + "line": 5, + "column": 31 + }, + "end": { + "line": 5, + "column": 41 + } + }, + "range": [ + 172, + 182 + ], + "name": "prefixIcon" + }, + "references": [ + { + "id": { + "type": "Identifier", + "start": 172, + "end": 182, + "loc": { + "start": { + "line": 5, + "column": 31 + }, + "end": { + "line": 5, + "column": 41 + } + }, + "range": [ + 172, + 182 + ], + "name": "prefixIcon" + }, + "mode": "r" + } + ] + } + }, + { + "type": "VAttribute", + "range": [ + 184, + 202 + ], + "loc": { + "start": { + "line": 5, + "column": 43 + }, + "end": { + "line": 5, + "column": 61 + } + }, + "directive": true, + "key": { + "type": "VDirectiveKey", + "range": [ + 184, + 189 + ], + "loc": { + "start": { + "line": 5, + "column": 43 + }, + "end": { + "line": 5, + "column": 48 + } + }, + "name": { + "type": "VIdentifier", + "range": [ + 184, + 185 + ], + "loc": { + "start": { + "column": 43, + "line": 5 + }, + "end": { + "column": 44, + "line": 5 + } + }, + "name": "bind", + "rawName": ":" + }, + "argument": { + "type": "VIdentifier", + "range": [ + 185, + 189 + ], + "loc": { + "start": { + "column": 44, + "line": 5 + }, + "end": { + "column": 48, + "line": 5 + } + }, + "name": "icon", + "rawName": "icon" + }, + "modifiers": [] + }, + "value": { + "type": "VExpressionContainer", + "range": [ + 190, + 202 + ], + "loc": { + "start": { + "line": 5, + "column": 49 + }, + "end": { + "line": 5, + "column": 61 + } + }, + "expression": { + "type": "Identifier", + "start": 191, + "end": 201, + "loc": { + "start": { + "line": 5, + "column": 50 + }, + "end": { + "line": 5, + "column": 60 + } + }, + "range": [ + 191, + 201 + ], + "name": "prefixIcon" + }, + "references": [ + { + "id": { + "type": "Identifier", + "start": 191, + "end": 201, + "loc": { + "start": { + "line": 5, + "column": 50 + }, + "end": { + "line": 5, + "column": 60 + } + }, + "range": [ + 191, + 201 + ], + "name": "prefixIcon" + }, + "mode": "r" + } + ] + } + }, + { + "type": "VAttribute", + "range": [ + 203, + 213 + ], + "loc": { + "start": { + "line": 5, + "column": 62 + }, + "end": { + "line": 5, + "column": 72 + } + }, + "directive": false, + "key": { + "type": "VIdentifier", + "range": [ + 203, + 213 + ], + "loc": { + "start": { + "line": 5, + "column": 62 + }, + "end": { + "line": 5, + "column": 72 + } + }, + "name": "fixedwidth", + "rawName": "fixedWidth" + }, + "value": null + } + ] + }, + "children": [], + "endTag": null, + "variables": [] + }, + { + "type": "VText", + "range": [ + 216, + 223 + ], + "loc": { + "start": { + "line": 5, + "column": 75 + }, + "end": { + "line": 6, + "column": 6 + } + }, + "value": "\n " + } + ], + "endTag": { + "type": "VEndTag", + "range": [ + 223, + 230 + ], + "loc": { + "start": { + "line": 6, + "column": 6 + }, + "end": { + "line": 6, + "column": 13 + } + } + }, + "variables": [] + }, + { + "type": "VText", + "range": [ + 230, + 235 + ], + "loc": { + "start": { + "line": 6, + "column": 13 + }, + "end": { + "line": 7, + "column": 4 + } + }, + "value": "\n " + } + ], + "endTag": { + "type": "VEndTag", + "range": [ + 235, + 242 + ], + "loc": { + "start": { + "line": 7, + "column": 4 + }, + "end": { + "line": 7, + "column": 11 + } + } + }, + "variables": [] + }, + { + "type": "VText", + "range": [ + 242, + 247 + ], + "loc": { + "start": { + "line": 7, + "column": 11 + }, + "end": { + "line": 8, + "column": 4 + } + }, + "value": "\n " + }, + { + "type": "VElement", + "range": [ + 247, + 255 + ], + "loc": { + "start": { + "line": 8, + "column": 4 + }, + "end": { + "line": 8, + "column": 12 + } + }, + "name": "slot", + "rawName": "slot", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 247, + 255 + ], + "loc": { + "start": { + "line": 8, + "column": 4 + }, + "end": { + "line": 8, + "column": 12 + } + }, + "selfClosing": true, + "attributes": [] + }, + "children": [], + "endTag": null, + "variables": [] + }, + { + "type": "VText", + "range": [ + 255, + 258 + ], + "loc": { + "start": { + "line": 8, + "column": 12 + }, + "end": { + "line": 9, + "column": 2 + } + }, + "value": "\n " + } + ], + "endTag": { + "type": "VEndTag", + "range": [ + 258, + 265 + ], + "loc": { + "start": { + "line": 9, + "column": 2 + }, + "end": { + "line": 9, + "column": 9 + } + } + }, + "variables": [] + }, + { + "type": "VText", + "range": [ + 265, + 266 + ], + "loc": { + "start": { + "line": 9, + "column": 9 + }, + "end": { + "line": 10, + "column": 0 + } + }, + "value": "\n" + } + ], + "endTag": { + "type": "VEndTag", + "range": [ + 266, + 277 + ], + "loc": { + "start": { + "line": 10, + "column": 0 + }, + "end": { + "line": 10, + "column": 11 + } + } + }, + "variables": [], + "tokens": [ + { + "type": "HTMLTagOpen", + "range": [ + 0, + 9 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 9, + 10 + ], + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 10, + 13 + ], + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 2, + "column": 2 + } + }, + "value": "\n " + }, + { + "type": "HTMLTagOpen", + "range": [ + 13, + 18 + ], + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 7 + } + }, + "value": "link" + }, + { + "type": "Punctuator", + "range": [ + 19, + 20 + ], + "loc": { + "start": { + "column": 8, + "line": 2 + }, + "end": { + "column": 9, + "line": 2 + } + }, + "value": ":" + }, + { + "type": "HTMLIdentifier", + "range": [ + 20, + 22 + ], + "loc": { + "start": { + "column": 9, + "line": 2 + }, + "end": { + "column": 11, + "line": 2 + } + }, + "value": "to" + }, + { + "type": "HTMLAssociation", + "range": [ + 22, + 23 + ], + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 2, + "column": 12 + } + }, + "value": "" + }, + { + "type": "Punctuator", + "range": [ + 23, + 24 + ], + "loc": { + "start": { + "line": 2, + "column": 12 + }, + "end": { + "line": 2, + "column": 13 + } + }, + "value": "\"" + }, + { + "type": "Identifier", + "value": "to", + "start": 24, + "end": 26, + "loc": { + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 2, + "column": 15 + } + }, + "range": [ + 24, + 26 + ] + }, + { + "type": "Punctuator", + "range": [ + 26, + 27 + ], + "loc": { + "start": { + "line": 2, + "column": 15 + }, + "end": { + "line": 2, + "column": 16 + } + }, + "value": "\"" + }, + { + "type": "HTMLIdentifier", + "range": [ + 28, + 33 + ], + "loc": { + "start": { + "line": 2, + "column": 17 + }, + "end": { + "line": 2, + "column": 22 + } + }, + "value": "class" + }, + { + "type": "HTMLAssociation", + "range": [ + 33, + 34 + ], + "loc": { + "start": { + "line": 2, + "column": 22 + }, + "end": { + "line": 2, + "column": 23 + } + }, + "value": "" + }, + { + "type": "HTMLLiteral", + "range": [ + 34, + 53 + ], + "loc": { + "start": { + "line": 2, + "column": 23 + }, + "end": { + "line": 2, + "column": 42 + } + }, + "value": "flex items-center" + }, + { + "type": "HTMLTagClose", + "range": [ + 53, + 54 + ], + "loc": { + "start": { + "line": 2, + "column": 42 + }, + "end": { + "line": 2, + "column": 43 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 54, + 59 + ], + "loc": { + "start": { + "line": 2, + "column": 43 + }, + "end": { + "line": 3, + "column": 4 + } + }, + "value": "\n " + }, + { + "type": "HTMLTagOpen", + "range": [ + 59, + 64 + ], + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 9 + } + }, + "value": "span" + }, + { + "type": "HTMLIdentifier", + "range": [ + 65, + 69 + ], + "loc": { + "start": { + "column": 10, + "line": 3 + }, + "end": { + "column": 14, + "line": 3 + } + }, + "value": "v-if" + }, + { + "type": "HTMLAssociation", + "range": [ + 69, + 70 + ], + "loc": { + "start": { + "line": 3, + "column": 14 + }, + "end": { + "line": 3, + "column": 15 + } + }, + "value": "" + }, + { + "type": "Punctuator", + "range": [ + 70, + 71 + ], + "loc": { + "start": { + "line": 3, + "column": 15 + }, + "end": { + "line": 3, + "column": 16 + } + }, + "value": "\"" + }, + { + "type": "Identifier", + "value": "prefixIcon", + "start": 71, + "end": 81, + "loc": { + "start": { + "line": 3, + "column": 16 + }, + "end": { + "line": 3, + "column": 26 + } + }, + "range": [ + 71, + 81 + ] + }, + { + "type": "Punctuator", + "value": "||", + "start": 82, + "end": 84, + "loc": { + "start": { + "line": 3, + "column": 27 + }, + "end": { + "line": 3, + "column": 29 + } + }, + "range": [ + 82, + 84 + ] + }, + { + "type": "Identifier", + "value": "$slots", + "start": 85, + "end": 91, + "loc": { + "start": { + "line": 3, + "column": 30 + }, + "end": { + "line": 3, + "column": 36 + } + }, + "range": [ + 85, + 91 + ] + }, + { + "type": "Punctuator", + "value": ".", + "start": 91, + "end": 92, + "loc": { + "start": { + "line": 3, + "column": 36 + }, + "end": { + "line": 3, + "column": 37 + } + }, + "range": [ + 91, + 92 + ] + }, + { + "type": "Identifier", + "value": "prefix", + "start": 92, + "end": 98, + "loc": { + "start": { + "line": 3, + "column": 37 + }, + "end": { + "line": 3, + "column": 43 + } + }, + "range": [ + 92, + 98 + ] + }, + { + "type": "Punctuator", + "range": [ + 98, + 99 + ], + "loc": { + "start": { + "line": 3, + "column": 43 + }, + "end": { + "line": 3, + "column": 44 + } + }, + "value": "\"" + }, + { + "type": "HTMLIdentifier", + "range": [ + 100, + 105 + ], + "loc": { + "start": { + "line": 3, + "column": 45 + }, + "end": { + "line": 3, + "column": 50 + } + }, + "value": "class" + }, + { + "type": "HTMLAssociation", + "range": [ + 105, + 106 + ], + "loc": { + "start": { + "line": 3, + "column": 50 + }, + "end": { + "line": 3, + "column": 51 + } + }, + "value": "" + }, + { + "type": "HTMLLiteral", + "range": [ + 106, + 112 + ], + "loc": { + "start": { + "line": 3, + "column": 51 + }, + "end": { + "line": 3, + "column": 57 + } + }, + "value": "mr-1" + }, + { + "type": "HTMLTagClose", + "range": [ + 112, + 113 + ], + "loc": { + "start": { + "line": 3, + "column": 57 + }, + "end": { + "line": 3, + "column": 58 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 113, + 120 + ], + "loc": { + "start": { + "line": 3, + "column": 58 + }, + "end": { + "line": 4, + "column": 6 + } + }, + "value": "\n " + }, + { + "type": "HTMLTagOpen", + "range": [ + 120, + 125 + ], + "loc": { + "start": { + "line": 4, + "column": 6 + }, + "end": { + "line": 4, + "column": 11 + } + }, + "value": "slot" + }, + { + "type": "HTMLIdentifier", + "range": [ + 126, + 130 + ], + "loc": { + "start": { + "line": 4, + "column": 12 + }, + "end": { + "line": 4, + "column": 16 + } + }, + "value": "name" + }, + { + "type": "HTMLAssociation", + "range": [ + 130, + 131 + ], + "loc": { + "start": { + "line": 4, + "column": 16 + }, + "end": { + "line": 4, + "column": 17 + } + }, + "value": "" + }, + { + "type": "HTMLLiteral", + "range": [ + 131, + 139 + ], + "loc": { + "start": { + "line": 4, + "column": 17 + }, + "end": { + "line": 4, + "column": 25 + } + }, + "value": "prefix" + }, + { + "type": "HTMLTagClose", + "range": [ + 139, + 140 + ], + "loc": { + "start": { + "line": 4, + "column": 25 + }, + "end": { + "line": 4, + "column": 26 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 140, + 149 + ], + "loc": { + "start": { + "line": 4, + "column": 26 + }, + "end": { + "line": 5, + "column": 8 + } + }, + "value": "\n " + }, + { + "type": "HTMLTagOpen", + "range": [ + 149, + 165 + ], + "loc": { + "start": { + "line": 5, + "column": 8 + }, + "end": { + "line": 5, + "column": 24 + } + }, + "value": "fontawesomeicon" + }, + { + "type": "HTMLIdentifier", + "range": [ + 166, + 170 + ], + "loc": { + "start": { + "column": 25, + "line": 5 + }, + "end": { + "column": 29, + "line": 5 + } + }, + "value": "v-if" + }, + { + "type": "HTMLAssociation", + "range": [ + 170, + 171 + ], + "loc": { + "start": { + "line": 5, + "column": 29 + }, + "end": { + "line": 5, + "column": 30 + } + }, + "value": "" + }, + { + "type": "Punctuator", + "range": [ + 171, + 172 + ], + "loc": { + "start": { + "line": 5, + "column": 30 + }, + "end": { + "line": 5, + "column": 31 + } + }, + "value": "\"" + }, + { + "type": "Identifier", + "value": "prefixIcon", + "start": 172, + "end": 182, + "loc": { + "start": { + "line": 5, + "column": 31 + }, + "end": { + "line": 5, + "column": 41 + } + }, + "range": [ + 172, + 182 + ] + }, + { + "type": "Punctuator", + "range": [ + 182, + 183 + ], + "loc": { + "start": { + "line": 5, + "column": 41 + }, + "end": { + "line": 5, + "column": 42 + } + }, + "value": "\"" + }, + { + "type": "Punctuator", + "range": [ + 184, + 185 + ], + "loc": { + "start": { + "column": 43, + "line": 5 + }, + "end": { + "column": 44, + "line": 5 + } + }, + "value": ":" + }, + { + "type": "HTMLIdentifier", + "range": [ + 185, + 189 + ], + "loc": { + "start": { + "column": 44, + "line": 5 + }, + "end": { + "column": 48, + "line": 5 + } + }, + "value": "icon" + }, + { + "type": "HTMLAssociation", + "range": [ + 189, + 190 + ], + "loc": { + "start": { + "line": 5, + "column": 48 + }, + "end": { + "line": 5, + "column": 49 + } + }, + "value": "" + }, + { + "type": "Punctuator", + "range": [ + 190, + 191 + ], + "loc": { + "start": { + "line": 5, + "column": 49 + }, + "end": { + "line": 5, + "column": 50 + } + }, + "value": "\"" + }, + { + "type": "Identifier", + "value": "prefixIcon", + "start": 191, + "end": 201, + "loc": { + "start": { + "line": 5, + "column": 50 + }, + "end": { + "line": 5, + "column": 60 + } + }, + "range": [ + 191, + 201 + ] + }, + { + "type": "Punctuator", + "range": [ + 201, + 202 + ], + "loc": { + "start": { + "line": 5, + "column": 60 + }, + "end": { + "line": 5, + "column": 61 + } + }, + "value": "\"" + }, + { + "type": "HTMLIdentifier", + "range": [ + 203, + 213 + ], + "loc": { + "start": { + "line": 5, + "column": 62 + }, + "end": { + "line": 5, + "column": 72 + } + }, + "value": "fixedwidth" + }, + { + "type": "HTMLSelfClosingTagClose", + "range": [ + 214, + 216 + ], + "loc": { + "start": { + "line": 5, + "column": 73 + }, + "end": { + "line": 5, + "column": 75 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 216, + 223 + ], + "loc": { + "start": { + "line": 5, + "column": 75 + }, + "end": { + "line": 6, + "column": 6 + } + }, + "value": "\n " + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 223, + 229 + ], + "loc": { + "start": { + "line": 6, + "column": 6 + }, + "end": { + "line": 6, + "column": 12 + } + }, + "value": "slot" + }, + { + "type": "HTMLTagClose", + "range": [ + 229, + 230 + ], + "loc": { + "start": { + "line": 6, + "column": 12 + }, + "end": { + "line": 6, + "column": 13 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 230, + 235 + ], + "loc": { + "start": { + "line": 6, + "column": 13 + }, + "end": { + "line": 7, + "column": 4 + } + }, + "value": "\n " + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 235, + 241 + ], + "loc": { + "start": { + "line": 7, + "column": 4 + }, + "end": { + "line": 7, + "column": 10 + } + }, + "value": "span" + }, + { + "type": "HTMLTagClose", + "range": [ + 241, + 242 + ], + "loc": { + "start": { + "line": 7, + "column": 10 + }, + "end": { + "line": 7, + "column": 11 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 242, + 247 + ], + "loc": { + "start": { + "line": 7, + "column": 11 + }, + "end": { + "line": 8, + "column": 4 + } + }, + "value": "\n " + }, + { + "type": "HTMLTagOpen", + "range": [ + 247, + 252 + ], + "loc": { + "start": { + "line": 8, + "column": 4 + }, + "end": { + "line": 8, + "column": 9 + } + }, + "value": "slot" + }, + { + "type": "HTMLSelfClosingTagClose", + "range": [ + 253, + 255 + ], + "loc": { + "start": { + "line": 8, + "column": 10 + }, + "end": { + "line": 8, + "column": 12 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 255, + 258 + ], + "loc": { + "start": { + "line": 8, + "column": 12 + }, + "end": { + "line": 9, + "column": 2 + } + }, + "value": "\n " + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 258, + 264 + ], + "loc": { + "start": { + "line": 9, + "column": 2 + }, + "end": { + "line": 9, + "column": 8 + } + }, + "value": "link" + }, + { + "type": "HTMLTagClose", + "range": [ + 264, + 265 + ], + "loc": { + "start": { + "line": 9, + "column": 8 + }, + "end": { + "line": 9, + "column": 9 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 265, + 266 + ], + "loc": { + "start": { + "line": 9, + "column": 9 + }, + "end": { + "line": 10, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 266, + 276 + ], + "loc": { + "start": { + "line": 10, + "column": 0 + }, + "end": { + "line": 10, + "column": 10 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 276, + 277 + ], + "loc": { + "start": { + "line": 10, + "column": 10 + }, + "end": { + "line": 10, + "column": 11 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 277, + 278 + ], + "loc": { + "start": { + "line": 10, + "column": 11 + }, + "end": { + "line": 11, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLWhitespace", + "range": [ + 346, + 347 + ], + "loc": { + "start": { + "line": 11, + "column": 68 + }, + "end": { + "line": 12, + "column": 0 + } + }, + "value": "\n" + } + ], + "comments": [ + { + "type": "HTMLComment", + "range": [ + 278, + 346 + ], + "loc": { + "start": { + "line": 11, + "column": 0 + }, + "end": { + "line": 11, + "column": 68 + } + }, + "value": " from https://github.com/vuejs/eslint-plugin-vue/issues/1439 " + } + ], + "errors": [ + { + "message": "non-void-html-element-start-tag-with-trailing-solidus", + "index": 149, + "lineNumber": 5, + "column": 8 + }, + { + "message": "non-void-html-element-start-tag-with-trailing-solidus", + "index": 247, + "lineNumber": 8, + "column": 4 + } + ] + } +} \ No newline at end of file diff --git a/test/fixtures/ast/link-component/source.vue b/test/fixtures/ast/link-component/source.vue new file mode 100644 index 00000000..5f81ad87 --- /dev/null +++ b/test/fixtures/ast/link-component/source.vue @@ -0,0 +1,11 @@ + + diff --git a/test/fixtures/ast/link-component/token-ranges.json b/test/fixtures/ast/link-component/token-ranges.json new file mode 100644 index 00000000..4a579f82 --- /dev/null +++ b/test/fixtures/ast/link-component/token-ranges.json @@ -0,0 +1,70 @@ +[ + "", + "\n ", + "", + "\n ", + "", + "\n ", + "", + "\n ", + "", + "\n ", + "", + "\n ", + "", + "\n ", + "", + "\n ", + "", + "\n", + "", + "\n", + "\n", + "" +] \ No newline at end of file diff --git a/test/fixtures/ast/link-component/tree.json b/test/fixtures/ast/link-component/tree.json new file mode 100644 index 00000000..640c4961 --- /dev/null +++ b/test/fixtures/ast/link-component/tree.json @@ -0,0 +1,340 @@ +[ + { + "type": "VElement", + "text": "", + "children": [ + { + "type": "VStartTag", + "text": "", + "children": [] + } + ] + } +] \ No newline at end of file diff --git a/test/fixtures/ast/svg-upper/ast.json b/test/fixtures/ast/svg-upper/ast.json new file mode 100644 index 00000000..24ac6fb7 --- /dev/null +++ b/test/fixtures/ast/svg-upper/ast.json @@ -0,0 +1,743 @@ +{ + "type": "Program", + "start": 0, + "end": 0, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 0 + } + }, + "range": [ + 0, + 0 + ], + "body": [], + "sourceType": "script", + "comments": [], + "tokens": [], + "templateBody": { + "type": "VElement", + "range": [ + 0, + 90 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 11 + } + }, + "name": "template", + "rawName": "template", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 0, + 10 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "selfClosing": false, + "attributes": [] + }, + "children": [ + { + "type": "VText", + "range": [ + 10, + 15 + ], + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 2, + "column": 4 + } + }, + "value": "\n " + }, + { + "type": "VElement", + "range": [ + 15, + 78 + ], + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 3, + "column": 10 + } + }, + "name": "svg", + "rawName": "SVG", + "namespace": "http://www.w3.org/1999/xhtml", + "startTag": { + "type": "VStartTag", + "range": [ + 15, + 67 + ], + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 56 + } + }, + "selfClosing": false, + "attributes": [ + { + "type": "VAttribute", + "range": [ + 20, + 31 + ], + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 20 + } + }, + "directive": false, + "key": { + "type": "VIdentifier", + "range": [ + 20, + 25 + ], + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 14 + } + }, + "name": "width", + "rawName": "Width" + }, + "value": { + "type": "VLiteral", + "range": [ + 26, + 31 + ], + "loc": { + "start": { + "line": 2, + "column": 15 + }, + "end": { + "line": 2, + "column": 20 + } + }, + "value": "100" + } + }, + { + "type": "VAttribute", + "range": [ + 32, + 44 + ], + "loc": { + "start": { + "line": 2, + "column": 21 + }, + "end": { + "line": 2, + "column": 33 + } + }, + "directive": false, + "key": { + "type": "VIdentifier", + "range": [ + 32, + 38 + ], + "loc": { + "start": { + "line": 2, + "column": 21 + }, + "end": { + "line": 2, + "column": 27 + } + }, + "name": "height", + "rawName": "heiGht" + }, + "value": { + "type": "VLiteral", + "range": [ + 39, + 44 + ], + "loc": { + "start": { + "line": 2, + "column": 28 + }, + "end": { + "line": 2, + "column": 33 + } + }, + "value": "100" + } + }, + { + "type": "VAttribute", + "range": [ + 45, + 66 + ], + "loc": { + "start": { + "line": 2, + "column": 34 + }, + "end": { + "line": 2, + "column": 55 + } + }, + "directive": false, + "key": { + "type": "VIdentifier", + "range": [ + 45, + 52 + ], + "loc": { + "start": { + "line": 2, + "column": 34 + }, + "end": { + "line": 2, + "column": 41 + } + }, + "name": "viewbox", + "rawName": "viewbox" + }, + "value": { + "type": "VLiteral", + "range": [ + 53, + 66 + ], + "loc": { + "start": { + "line": 2, + "column": 42 + }, + "end": { + "line": 2, + "column": 55 + } + }, + "value": "0 0 100 100" + } + } + ] + }, + "children": [ + { + "type": "VText", + "range": [ + 67, + 72 + ], + "loc": { + "start": { + "line": 2, + "column": 56 + }, + "end": { + "line": 3, + "column": 4 + } + }, + "value": "\n " + } + ], + "endTag": { + "type": "VEndTag", + "range": [ + 72, + 78 + ], + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 10 + } + } + }, + "variables": [] + }, + { + "type": "VText", + "range": [ + 78, + 79 + ], + "loc": { + "start": { + "line": 3, + "column": 10 + }, + "end": { + "line": 4, + "column": 0 + } + }, + "value": "\n" + } + ], + "endTag": { + "type": "VEndTag", + "range": [ + 79, + 90 + ], + "loc": { + "start": { + "line": 4, + "column": 0 + }, + "end": { + "line": 4, + "column": 11 + } + } + }, + "variables": [], + "tokens": [ + { + "type": "HTMLTagOpen", + "range": [ + 0, + 9 + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 9 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 9, + 10 + ], + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 10, + 15 + ], + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 2, + "column": 4 + } + }, + "value": "\n " + }, + { + "type": "HTMLTagOpen", + "range": [ + 15, + 19 + ], + "loc": { + "start": { + "line": 2, + "column": 4 + }, + "end": { + "line": 2, + "column": 8 + } + }, + "value": "svg" + }, + { + "type": "HTMLIdentifier", + "range": [ + 20, + 25 + ], + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 14 + } + }, + "value": "width" + }, + { + "type": "HTMLAssociation", + "range": [ + 25, + 26 + ], + "loc": { + "start": { + "line": 2, + "column": 14 + }, + "end": { + "line": 2, + "column": 15 + } + }, + "value": "" + }, + { + "type": "HTMLLiteral", + "range": [ + 26, + 31 + ], + "loc": { + "start": { + "line": 2, + "column": 15 + }, + "end": { + "line": 2, + "column": 20 + } + }, + "value": "100" + }, + { + "type": "HTMLIdentifier", + "range": [ + 32, + 38 + ], + "loc": { + "start": { + "line": 2, + "column": 21 + }, + "end": { + "line": 2, + "column": 27 + } + }, + "value": "height" + }, + { + "type": "HTMLAssociation", + "range": [ + 38, + 39 + ], + "loc": { + "start": { + "line": 2, + "column": 27 + }, + "end": { + "line": 2, + "column": 28 + } + }, + "value": "" + }, + { + "type": "HTMLLiteral", + "range": [ + 39, + 44 + ], + "loc": { + "start": { + "line": 2, + "column": 28 + }, + "end": { + "line": 2, + "column": 33 + } + }, + "value": "100" + }, + { + "type": "HTMLIdentifier", + "range": [ + 45, + 52 + ], + "loc": { + "start": { + "line": 2, + "column": 34 + }, + "end": { + "line": 2, + "column": 41 + } + }, + "value": "viewbox" + }, + { + "type": "HTMLAssociation", + "range": [ + 52, + 53 + ], + "loc": { + "start": { + "line": 2, + "column": 41 + }, + "end": { + "line": 2, + "column": 42 + } + }, + "value": "" + }, + { + "type": "HTMLLiteral", + "range": [ + 53, + 66 + ], + "loc": { + "start": { + "line": 2, + "column": 42 + }, + "end": { + "line": 2, + "column": 55 + } + }, + "value": "0 0 100 100" + }, + { + "type": "HTMLTagClose", + "range": [ + 66, + 67 + ], + "loc": { + "start": { + "line": 2, + "column": 55 + }, + "end": { + "line": 2, + "column": 56 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 67, + 72 + ], + "loc": { + "start": { + "line": 2, + "column": 56 + }, + "end": { + "line": 3, + "column": 4 + } + }, + "value": "\n " + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 72, + 77 + ], + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 9 + } + }, + "value": "svg" + }, + { + "type": "HTMLTagClose", + "range": [ + 77, + 78 + ], + "loc": { + "start": { + "line": 3, + "column": 9 + }, + "end": { + "line": 3, + "column": 10 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 78, + 79 + ], + "loc": { + "start": { + "line": 3, + "column": 10 + }, + "end": { + "line": 4, + "column": 0 + } + }, + "value": "\n" + }, + { + "type": "HTMLEndTagOpen", + "range": [ + 79, + 89 + ], + "loc": { + "start": { + "line": 4, + "column": 0 + }, + "end": { + "line": 4, + "column": 10 + } + }, + "value": "template" + }, + { + "type": "HTMLTagClose", + "range": [ + 89, + 90 + ], + "loc": { + "start": { + "line": 4, + "column": 10 + }, + "end": { + "line": 4, + "column": 11 + } + }, + "value": "" + }, + { + "type": "HTMLWhitespace", + "range": [ + 90, + 91 + ], + "loc": { + "start": { + "line": 4, + "column": 11 + }, + "end": { + "line": 5, + "column": 0 + } + }, + "value": "\n" + } + ], + "comments": [], + "errors": [] + } +} \ No newline at end of file diff --git a/test/fixtures/ast/svg-upper/source.vue b/test/fixtures/ast/svg-upper/source.vue new file mode 100644 index 00000000..38ed7f68 --- /dev/null +++ b/test/fixtures/ast/svg-upper/source.vue @@ -0,0 +1,4 @@ + diff --git a/test/fixtures/ast/svg-upper/token-ranges.json b/test/fixtures/ast/svg-upper/token-ranges.json new file mode 100644 index 00000000..e473bac2 --- /dev/null +++ b/test/fixtures/ast/svg-upper/token-ranges.json @@ -0,0 +1,23 @@ +[ + "", + "\n ", + "", + "\n ", + "", + "\n", + "", + "\n" +] \ No newline at end of file diff --git a/test/fixtures/ast/svg-upper/tree.json b/test/fixtures/ast/svg-upper/tree.json new file mode 100644 index 00000000..d51fc5c2 --- /dev/null +++ b/test/fixtures/ast/svg-upper/tree.json @@ -0,0 +1,98 @@ +[ + { + "type": "VElement", + "text": "", + "children": [ + { + "type": "VStartTag", + "text": "", + "children": [] + } + ] + } +] \ No newline at end of file