@@ -24,21 +24,29 @@ module.exports = function(css, options){
24
24
*/
25
25
26
26
function position ( ) {
27
- var start = { line : lineno , column : column } ;
28
27
if ( ! options . position ) return positionNoop ;
29
28
30
- return function ( node ) {
31
- node . position = {
32
- start : start ,
33
- end : { line : lineno , column : column } ,
34
- source : options . source
35
- } ;
29
+ var start = { line : lineno , column : column } ;
36
30
31
+ return function ( node ) {
32
+ node . position = new Position ( start ) ;
37
33
whitespace ( ) ;
38
34
return node ;
39
35
}
40
36
}
41
37
38
+ function Position ( start ) {
39
+ this . start = start ;
40
+ this . end = { line : lineno , column : column } ;
41
+ this . filename = options . filename ;
42
+ }
43
+
44
+ /**
45
+ * Non-enumerable source string.
46
+ */
47
+
48
+ Position . prototype . source = css ;
49
+
42
50
/**
43
51
* Return `node`.
44
52
*/
@@ -52,12 +60,9 @@ module.exports = function(css, options){
52
60
* Error `msg`.
53
61
*/
54
62
55
- function error ( msg ) {
63
+ function error ( msg , start ) {
56
64
var err = new Error ( msg + ' near line ' + lineno + ':' + column ) ;
57
- err . filename = options . source ;
58
- err . line = lineno ;
59
- err . column = column ;
60
- err . source = css ;
65
+ err . position = new Position ( start ) ;
61
66
throw err ;
62
67
}
63
68
@@ -169,7 +174,7 @@ module.exports = function(css, options){
169
174
function selector ( ) {
170
175
var m = match ( / ^ ( [ ^ { ] + ) / ) ;
171
176
if ( ! m ) return ;
172
- /* @fix Remove all comments from selectors
177
+ /* @fix Remove all comments from selectors
173
178
* http://ostermiller.org/findcomment.html */
174
179
return trim ( m [ 0 ] ) . replace ( / \/ \* ( [ ^ * ] | [ \r \n ] | ( \* + ( [ ^ * / ] | [ \r \n ] ) ) ) * \* \/ + / g, '' ) . split ( / \s * , \s * / ) ;
175
180
}
0 commit comments