htmljs-parser
Advanced tools
Comparing version 1.4.3 to 1.5.0
@@ -108,2 +108,6 @@ 'use strict'; | ||
substring(pos, endPos) { | ||
return this.data.substring(pos, endPos); | ||
} | ||
parse(data) { | ||
@@ -110,0 +114,0 @@ if (data == null) { |
@@ -71,2 +71,3 @@ exports.createNotifiers = function(parser, listeners) { | ||
tagName: tagInfo.tagName, | ||
tagNameExpression: tagInfo.tagNameExpression, | ||
argument: tagInfo.argument, | ||
@@ -80,2 +81,10 @@ pos: tagInfo.pos, | ||
if (tagInfo.shorthandId) { | ||
event.shorthandId = tagInfo.shorthandId; | ||
} | ||
if (tagInfo.shorthandClassNames) { | ||
event.shorthandClassNames = tagInfo.shorthandClassNames; | ||
} | ||
event.attributes = tagInfo.attributes.map((attr) => { | ||
@@ -205,2 +214,3 @@ var newAttr = { | ||
withinOpenTag: placeholder.withinOpenTag === true, | ||
withinTagName: placeholder.withinTagName === true | ||
}; | ||
@@ -207,0 +217,0 @@ |
@@ -38,3 +38,3 @@ { | ||
}, | ||
"version": "1.4.3" | ||
"version": "1.5.0" | ||
} |
@@ -9,2 +9,3 @@ var chai = require('chai'); | ||
var TreeBuilder = require('./TreeBuilder'); | ||
var expect = require('chai').expect; | ||
@@ -55,5 +56,6 @@ require('colors'); | ||
var inputPath = path.join(dir, 'input.htmljs'); | ||
var inputHtmlJs = fs.readFileSync(inputPath, {encoding: 'utf8'}); | ||
var testOptionsPath = path.join(dir, 'test.js'); | ||
var options; | ||
var inputHtmlJs; | ||
@@ -64,2 +66,8 @@ if (fs.existsSync(testOptionsPath)) { | ||
if (options && options.getSource) { | ||
inputHtmlJs = options.getSource(); | ||
} else { | ||
inputHtmlJs = fs.readFileSync(inputPath, {encoding: 'utf8'}); | ||
} | ||
if (options && options.checkThrownError) { | ||
@@ -66,0 +74,0 @@ var error; |
@@ -103,2 +103,3 @@ 'use strict'; | ||
var tagName = event.tagName; | ||
var tagNameExpression = event.tagNameExpression; | ||
var argument = event.argument; | ||
@@ -111,2 +112,6 @@ var attributes = event.attributes; | ||
if (tagNameExpression) { | ||
str += '[' + tagNameExpression + ']'; | ||
} | ||
if (argument) { | ||
@@ -120,2 +125,12 @@ str += '(' + argument.value + ')'; | ||
if (event.shorthandId) { | ||
str += ' shorthandId=' + event.shorthandId.value; | ||
} | ||
if (event.shorthandClassNames) { | ||
str += ' shorthandClassNames=[' + event.shorthandClassNames.map((classNamePart) => { | ||
return classNamePart.value; | ||
}).join(', ') + ']'; | ||
} | ||
str += attributesToString(attributes, out.includeLiteralValues) + (openTagOnly ? ' OPEN_ONLY' : '') + (selfClosed ? ' SELF_CLOSED' : '') + '>'; | ||
@@ -170,2 +185,6 @@ out.writeLine(str); | ||
if (event.withinTagName) { | ||
return; | ||
} | ||
var escapeFunc = escape ? '$escapeXml' : '$noEscapeXml'; | ||
@@ -197,16 +216,20 @@ event.value = escapeFunc + '(' + event.value + ')'; | ||
// Make sure the position information is correct | ||
if (event.concise) { | ||
expect(src.substring(startPos, startPos + tagName.length)).to.equal(tagName); | ||
} else { | ||
expect(src.substring(startPos, startPos + 1 + tagName.length)).to.equal('<' + tagName); | ||
if (!event.shorthandId && !event.shorthandClassNames) { | ||
// Make sure the position information is correct, but only if the | ||
// shorthand syntax was not used on the tag name | ||
if (event.concise) { | ||
expect(src.substring(startPos, startPos + tagName.length)).to.equal(tagName); | ||
} else { | ||
expect(src.substring(startPos, startPos + 1 + tagName.length)).to.equal('<' + tagName); | ||
if (event.selfClosed) { | ||
expect(src.substring(endPos - 2, endPos)).to.equal('/>'); | ||
} else { | ||
expect(src.charAt(endPos-1)).to.equal('>'); | ||
if (event.selfClosed) { | ||
expect(src.substring(endPos - 2, endPos)).to.equal('/>'); | ||
} else { | ||
expect(src.charAt(endPos-1)).to.equal('>'); | ||
} | ||
} | ||
} | ||
var el = new ElementNode(event); | ||
@@ -245,3 +268,8 @@ this.last.children.push(el); | ||
} else { | ||
expect(src.substring(startPos, startPos + 2 + tagName.length + 1)).to.equal('</' + tagName + '>'); | ||
if (!lastEvent.shorthandId && !lastEvent.shorthandClassNames) { | ||
var actualEndTag = src.substring(startPos, endPos); | ||
if (actualEndTag !== '</' + tagName + '>' && actualEndTag !== '</>') { | ||
throw new Error('Incorrect start/stop pos for close tag: ' + actualEndTag); | ||
} | ||
} | ||
} | ||
@@ -248,0 +276,0 @@ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
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
163632
352
2972