@@ -29,29 +29,21 @@ module.exports = function(css, options){
2929 */
3030
3131 function position ( ) {
32- if ( ! options . position ) return positionNoop ;
33-
3432 var start = { line : lineno , column : column } ;
33+ if ( ! options . position ) return positionNoop ;
3534
3635 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+
3842 whitespace ( ) ;
3943 return node ;
4044 } ;
4145 }
4246
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-
5547 /**
5648 * Return `node`.
5749 */
@@ -65,9 +57,12 @@ module.exports = function(css, options){
6557 * Error `msg`.
6658 */
6759
68- function error ( msg , start ) {
60+ function error ( msg ) {
6961 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 ;
7166 throw err ;
7267 }
7368
@@ -183,7 +178,7 @@ module.exports = function(css, options){
183178 function selector ( ) {
184179 var m = match ( / ^ ( [ ^ { ] + ) / ) ;
185180 if ( ! m ) return ;
186- /* @fix Remove all comments from selectors
181+ /* @fix Remove all comments from selectors
187182 * http://ostermiller.org/findcomment.html */
188183 return trim ( m [ 0 ] ) . replace ( / \/ \* ( [ ^ * ] | [ \r \n ] | ( \* + ( [ ^ * / ] | [ \r \n ] ) ) ) * \* \/ + / g, '' ) . split ( / \s * , \s * / ) ;
189184 }
0 commit comments