css-parse
Advanced tools
Comparing version 1.4.0 to 1.5.0
{ | ||
"name": "css-parse", | ||
"repo": "visionmedia/css-parse", | ||
"version": "1.4.0", | ||
"version": "1.5.0", | ||
"description": "CSS parser", | ||
@@ -6,0 +6,0 @@ "keywords": ["css", "parser", "stylesheet"], |
1.5.0 / 2013-06-18 | ||
================== | ||
* add error reporting | ||
* fix @document with no vendor prefix | ||
1.4.0 / 2013-05-22 | ||
@@ -3,0 +9,0 @@ ================== |
45
index.js
@@ -52,2 +52,14 @@ | ||
/** | ||
* Error `msg`. | ||
*/ | ||
function error(msg) { | ||
var err = new Error(msg + ' near line ' + lineno + ':' + column); | ||
err.line = lineno; | ||
err.column = column; | ||
err.source = css; | ||
throw err; | ||
} | ||
/** | ||
* Parse stylesheet. | ||
@@ -176,7 +188,7 @@ */ | ||
// : | ||
if (!match(/^:\s*/)) return; | ||
if (!match(/^:\s*/)) return error("property missing ':'"); | ||
// val | ||
var val = match(/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^\)]*?\)|[^};])+)/); | ||
if (!val) return; | ||
if (!val) return error('property missing value'); | ||
@@ -191,2 +203,3 @@ var ret = pos({ | ||
match(/^[;\s]*/); | ||
return ret; | ||
@@ -202,3 +215,3 @@ } | ||
if (!open()) return; | ||
if (!open()) return error("missing '{'"); | ||
comments(decls); | ||
@@ -213,3 +226,3 @@ | ||
if (!close()) return; | ||
if (!close()) return error("missing '}'"); | ||
return decls; | ||
@@ -254,6 +267,6 @@ } | ||
var m = match(/^([-\w]+)\s*/); | ||
if (!m) return; | ||
if (!m) return error("@keyframes missing name"); | ||
var name = m[1]; | ||
if (!open()) return; | ||
if (!open()) return error("@keyframes missing '{'"); | ||
comments(); | ||
@@ -268,3 +281,3 @@ | ||
if (!close()) return; | ||
if (!close()) return error("@keyframes missing '}'"); | ||
@@ -290,3 +303,3 @@ return pos({ | ||
if (!open()) return; | ||
if (!open()) return error("@supports missing '{'"); | ||
comments(); | ||
@@ -296,3 +309,3 @@ | ||
if (!close()) return; | ||
if (!close()) return error("@supports missing '}'"); | ||
@@ -317,3 +330,3 @@ return pos({ | ||
if (!open()) return; | ||
if (!open()) return error("@media missing '{'"); | ||
comments(); | ||
@@ -323,3 +336,3 @@ | ||
if (!close()) return; | ||
if (!close()) return error("@media missing '}'"); | ||
@@ -345,3 +358,3 @@ return pos({ | ||
if (!open()) return; | ||
if (!open()) return error("@page missing '{'"); | ||
comments(); | ||
@@ -356,3 +369,3 @@ | ||
if (!close()) return; | ||
if (!close()) return error("@page missing '}'"); | ||
@@ -375,6 +388,6 @@ return pos({ | ||
var vendor = m[1].trim(); | ||
var vendor = (m[1] || '').trim(); | ||
var doc = m[2].trim(); | ||
if (!open()) return; | ||
if (!open()) return error("@document missing '{'"); | ||
comments(); | ||
@@ -384,3 +397,3 @@ | ||
if (!close()) return; | ||
if (!close()) return error("@document missing '}'"); | ||
@@ -387,0 +400,0 @@ return pos({ |
{ | ||
"name": "css-parse", | ||
"version": "1.4.0", | ||
"version": "1.5.0", | ||
"description": "CSS parser", | ||
@@ -5,0 +5,0 @@ "keywords": ["css", "parser", "stylesheet"], |
11341
369