@fimbul/ve
Advanced tools
Comparing version 0.11.0 to 0.12.0-dev.20180622
{ | ||
"name": "@fimbul/ve", | ||
"version": "0.11.0", | ||
"version": "0.12.0-dev.20180622", | ||
"description": "Vue processor for wotan", | ||
@@ -31,4 +31,4 @@ "main": "src/index", | ||
"dependencies": { | ||
"@fimbul/ymir": "^0.11.0", | ||
"parse5": "^4.0.0", | ||
"@fimbul/ymir": "0.11.0", | ||
"parse5-sax-parser": "^5.0.0", | ||
"tslib": "^1.8.1", | ||
@@ -35,0 +35,0 @@ "void-elements": "^3.1.0" |
@@ -5,3 +5,3 @@ "use strict"; | ||
const path = require("path"); | ||
const parse5 = require("parse5/lib"); | ||
const SAXParser = require("parse5-sax-parser"); | ||
const voidElements = require("void-elements"); | ||
@@ -17,15 +17,15 @@ class Processor extends ymir_1.AbstractProcessor { | ||
if (path.extname(this.sourceFileName) === '.vue') { | ||
const parser = new parse5.SAXParser({ locationInfo: true }); | ||
const parser = new SAXParser({ sourceCodeLocationInfo: true }); | ||
let depth = 0; | ||
parser.on('startTag', (tagName, _attr, selfClosing, location) => { | ||
if (selfClosing || voidElements[tagName]) | ||
parser.on('startTag', (startTag) => { | ||
if (startTag.selfClosing || voidElements[startTag.tagName]) | ||
return; | ||
++depth; | ||
if (depth === 1 && tagName === 'script') | ||
this.range.start = location.endOffset; | ||
if (depth === 1 && startTag.tagName === 'script') | ||
this.range.start = startTag.sourceCodeLocation.endOffset; | ||
}); | ||
parser.on('endTag', (tagName, location) => { | ||
parser.on('endTag', (endTag) => { | ||
--depth; | ||
if (depth === 0 && tagName === 'script') | ||
this.range.end = location.startOffset; | ||
if (depth === 0 && endTag.tagName === 'script') | ||
this.range.end = endTag.sourceCodeLocation.startOffset; | ||
}); | ||
@@ -43,10 +43,10 @@ parser.write(this.source); | ||
let suffix = ''; | ||
const parser = new parse5.SAXParser(); | ||
const parser = new SAXParser(); | ||
let depth = 0; | ||
parser.on('startTag', (tagName, attr, selfClosing) => { | ||
if (selfClosing || voidElements[tagName]) | ||
parser.on('startTag', (startTag) => { | ||
if (startTag.selfClosing || voidElements[startTag.tagName]) | ||
return; | ||
++depth; | ||
if (depth === 1 && tagName === 'script') { | ||
const lang = attr.find(isLangAttr); | ||
if (depth === 1 && startTag.tagName === 'script') { | ||
const lang = startTag.attrs.find((attr) => attr.name === 'lang'); | ||
suffix = lang === undefined ? '.js' : `.${lang.value}`; | ||
@@ -107,5 +107,2 @@ } | ||
exports.Processor = Processor; | ||
function isLangAttr(attr) { | ||
return attr.name === 'lang'; | ||
} | ||
//# sourceMappingURL=index.js.map |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
21788
103
+ Addedparse5-sax-parser@^5.0.0
+ Addedparse5@5.1.1(transitive)
+ Addedparse5-sax-parser@5.1.1(transitive)
- Removedparse5@^4.0.0
- Removedparse5@4.0.0(transitive)
Updated@fimbul/ymir@0.11.0