-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed a bug that caused an error with prefixed attributes. (#137)
- Loading branch information
Showing
4 changed files
with
49 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
"use strict" | ||
|
||
const assert = require("assert") | ||
const htmlParser = require("../../../lib/services/html-parser") | ||
const SourceCodeStore = require("../../../lib/services/source-code-store") | ||
|
||
/** | ||
* Parse html | ||
* @param {string} code source code | ||
*/ | ||
function parse(code) { | ||
const store = new SourceCodeStore(code) | ||
return htmlParser(code, store) | ||
} | ||
|
||
describe("html-parser test", () => { | ||
it("prefixed attributes", () => { | ||
// https://github.com/ota-meshi/eslint-plugin-lodash-template/issues/136 | ||
const ast = parse('<svg xml:space="preserve"></svg>') | ||
assert.strictEqual(ast.type, "HTMLDocumentFragment") | ||
assert.strictEqual(ast.children.length, 1) | ||
assert.strictEqual(ast.children[0].type, "HTMLElement") | ||
assert.strictEqual(ast.children[0].name, "svg") | ||
assert.strictEqual(ast.children[0].startTag.attributes.length, 1) | ||
assert.deepStrictEqual(ast.children[0].startTag.attributes[0].range, [ | ||
5, | ||
25, | ||
]) | ||
assert.strictEqual( | ||
ast.children[0].startTag.attributes[0].key, | ||
"xml:space" | ||
) | ||
assert.strictEqual( | ||
ast.children[0].startTag.attributes[0].value, | ||
"preserve" | ||
) | ||
}) | ||
}) |