Comparing version 1.0.0-alpha12 to 1.0.0-alpha13
@@ -0,1 +1,8 @@ | ||
## 1.0.0-alpha13 (January 19, 2017) | ||
- Changed location storing in `SyntaxMatchError` | ||
- Changed property to store mismatch offset to `mismatchOffset` | ||
- Changed `offset` property to store bad node offset in source CSS if any | ||
- Added `loc` property that stores bad node `loc` if any | ||
## 1.0.0-alpha12 (January 19, 2017) | ||
@@ -2,0 +9,0 @@ |
@@ -19,2 +19,12 @@ 'use strict'; | ||
function getLocation(node, point) { | ||
var loc = node && node.loc && node.loc[point]; | ||
return loc | ||
? { offset: loc.offset, | ||
line: loc.line, | ||
column: loc.column } | ||
: null; | ||
} | ||
var SyntaxParseError = function(message, syntaxStr, offset) { | ||
@@ -36,2 +46,5 @@ var error = new SyntaxError(); | ||
var css = ''; | ||
var error = new SyntaxError(message); | ||
var start = getLocation(badNode, 'start'); | ||
var end = getLocation(badNode, 'end'); | ||
@@ -50,3 +63,2 @@ value.children.each(function(node) { | ||
var error = new SyntaxError(message); | ||
error.name = 'SyntaxMatchError'; | ||
@@ -56,9 +68,15 @@ error.rawMessage = message; | ||
error.css = css; | ||
error.line = badNode && badNode.loc && badNode.loc.start ? badNode.loc.start.line : undefined; | ||
error.column = badNode && badNode.loc && badNode.loc.start ? badNode.loc.start.column : undefined; | ||
error.offset = errorOffset; | ||
error.mismatchOffset = errorOffset; | ||
error.loc = { | ||
source: badNode && badNode.loc && badNode.loc.source || '<unknown>', | ||
start: start, | ||
end: end | ||
}; | ||
error.line = start ? start.line : undefined; | ||
error.column = start ? start.column : undefined; | ||
error.offset = start ? start.offset : undefined; | ||
error.message = message + '\n' + | ||
' syntax: ' + error.syntax + '\n' + | ||
' value: ' + (error.css || '<empty string>') + '\n' + | ||
' --------' + new Array(error.offset + 1).join('-') + '^'; | ||
' --------' + new Array(error.mismatchOffset + 1).join('-') + '^'; | ||
@@ -65,0 +83,0 @@ return error; |
{ | ||
"name": "css-tree", | ||
"version": "1.0.0-alpha12", | ||
"version": "1.0.0-alpha13", | ||
"description": "Fast detailed CSS parser", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
Sorry, the diff of this file is too big to display
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
548235
12493