Comparing version 2.1.0 to 2.2.0
@@ -59,7 +59,5 @@ // http://www.w3.org/TR/CSS21/grammar.html | ||
var errorsList = []; | ||
function error(msg) { | ||
if (options.silent === true) { | ||
return false; | ||
} | ||
var err = new Error(options.source + ':' + lineno + ':' + column + ': ' + msg); | ||
@@ -71,3 +69,8 @@ err.reason = msg; | ||
err.source = css; | ||
throw err; | ||
if (options.silent) { | ||
errorsList.push(err); | ||
} else { | ||
throw err; | ||
} | ||
} | ||
@@ -80,6 +83,9 @@ | ||
function stylesheet() { | ||
var rulesList = rules(); | ||
return { | ||
type: 'stylesheet', | ||
stylesheet: { | ||
rules: rules() | ||
rules: rulesList, | ||
parsingErrors: errorsList | ||
} | ||
@@ -289,3 +295,3 @@ }; | ||
var pos = position(); | ||
var m = match(/^@([-\w]+)?keyframes */); | ||
var m = match(/^@([-\w]+)?keyframes\s*/); | ||
@@ -349,3 +355,3 @@ if (!m) return; | ||
var pos = position(); | ||
var m = match(/^@host */); | ||
var m = match(/^@host\s*/); | ||
@@ -397,3 +403,3 @@ if (!m) return; | ||
var pos = position(); | ||
var m = match(/^@custom-media (--[^\s]+) *([^{;]+);/); | ||
var m = match(/^@custom-media\s+(--[^\s]+)\s*([^{;]+);/); | ||
if (!m) return; | ||
@@ -470,3 +476,3 @@ | ||
var pos = position(); | ||
var m = match(/^@font-face */); | ||
var m = match(/^@font-face\s*/); | ||
if (!m) return; | ||
@@ -516,3 +522,3 @@ | ||
function _compileAtrule(name) { | ||
var re = new RegExp('^@' + name + ' *([^;\\n]+);'); | ||
var re = new RegExp('^@' + name + '\\s*([^;]+);'); | ||
return function() { | ||
@@ -519,0 +525,0 @@ var pos = position(); |
{ | ||
"name": "css", | ||
"version": "2.1.0", | ||
"version": "2.2.0", | ||
"description": "CSS parser / stringifier", | ||
@@ -5,0 +5,0 @@ "main": "index", |
@@ -35,2 +35,3 @@ # css [![Build Status](https://travis-ci.org/reworkcss/css.svg?branch=master)](https://travis-ci.org/reworkcss/css) | ||
- indent: the string used to indent the output. Defaults to two spaces. | ||
- compress: omit comments and extraneous whitespace. | ||
@@ -60,9 +61,19 @@ - sourcemap: return a sourcemap along with the CSS output. Using the `source` | ||
Errors will have `error.position`, just like [`node.position`](#position). The | ||
error contains the source position in the message. To get the error message | ||
without the position use `error.reason`. | ||
Errors thrown during parsing have the following properties: | ||
- message: `String`. The full error message with the source position. | ||
- reason: `String`. The error message without position. | ||
- filename: `String` or `undefined`. The value of `options.source` if | ||
passed to `css.parse`. Otherwise `undefined`. | ||
- line: `Integer`. | ||
- column: `Integer`. | ||
- source: `String`. The portion of code that couldn't be parsed. | ||
When parsing with the `silent` option, errors are listed in the | ||
`parsingErrors` property of the [`stylesheet`](#stylesheet) node instead | ||
of being thrown. | ||
If you create any errors in plugins such as in | ||
[rework](https://github.com/reworkcss/rework), you __must__ set the `position` | ||
as well for consistency. | ||
[rework](https://github.com/reworkcss/rework), you __must__ set the same | ||
properties for consistency. | ||
@@ -119,2 +130,4 @@ ## AST | ||
at-rule types. | ||
- parsingErrors: `Array` of `Error`s. Errors collected during parsing when | ||
option `silent` is true. | ||
@@ -121,0 +134,0 @@ #### rule |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
35058
11
1008
313
0