@@ -24,21 +24,29 @@ module.exports = function(css, options){
2424 */
2525
2626 function position ( ) {
27- var start = { line : lineno , column : column } ;
2827 if ( ! options . position ) return positionNoop ;
2928
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 } ;
3630
31+ return function ( node ) {
32+ node . position = new Position ( start ) ;
3733 whitespace ( ) ;
3834 return node ;
3935 }
4036 }
4137
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+
4250 /**
4351 * Return `node`.
4452 */
@@ -52,12 +60,9 @@ module.exports = function(css, options){
5260 * Error `msg`.
5361 */
5462
55- function error ( msg ) {
63+ function error ( msg , start ) {
5664 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 ) ;
6166 throw err ;
6267 }
6368
@@ -169,7 +174,7 @@ module.exports = function(css, options){
169174 function selector ( ) {
170175 var m = match ( / ^ ( [ ^ { ] + ) / ) ;
171176 if ( ! m ) return ;
172- /* @fix Remove all comments from selectors
177+ /* @fix Remove all comments from selectors
173178 * http://ostermiller.org/findcomment.html */
174179 return trim ( m [ 0 ] ) . replace ( / \/ \* ( [ ^ * ] | [ \r \n ] | ( \* + ( [ ^ * / ] | [ \r \n ] ) ) ) * \* \/ + / g, '' ) . split ( / \s * , \s * / ) ;
175180 }
0 commit comments