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