File tree Expand file tree Collapse file tree 2 files changed +46
-2
lines changed Expand file tree Collapse file tree 2 files changed +46
-2
lines changed Original file line number Diff line number Diff line change @@ -40,6 +40,26 @@ describe('no interpolations', () => {
4040 line : 1 ,
4141 column : 38 ,
4242 } ) ;
43+ expect ( decl . rangeBy ( { } ) ) . toEqual ( {
44+ start : {
45+ column : 28 ,
46+ line : 1 ,
47+ } ,
48+ end : {
49+ column : 39 ,
50+ line : 1 ,
51+ } ,
52+ } ) ;
53+ expect ( decl . rangeBy ( { word : 'red' } ) ) . toEqual ( {
54+ start : {
55+ column : 35 ,
56+ line : 1 ,
57+ } ,
58+ end : {
59+ column : 38 ,
60+ line : 1 ,
61+ } ,
62+ } ) ;
4363 } ) ;
4464
4565 test ( 'two components' , ( ) => {
@@ -111,6 +131,26 @@ describe('no interpolations', () => {
111131 line : 2 ,
112132 column : 45 ,
113133 } ) ;
134+ expect ( secondComponent . rangeBy ( { } ) ) . toEqual ( {
135+ start : {
136+ column : 28 ,
137+ line : 2 ,
138+ } ,
139+ end : {
140+ column : 47 ,
141+ line : 2 ,
142+ } ,
143+ } ) ;
144+ expect ( secondComponent . rangeBy ( { word : 'blue' } ) ) . toEqual ( {
145+ start : {
146+ column : 42 ,
147+ line : 2 ,
148+ } ,
149+ end : {
150+ column : 46 ,
151+ line : 2 ,
152+ } ,
153+ } ) ;
114154 } ) ;
115155
116156 test ( 'empty component' , ( ) => {
Original file line number Diff line number Diff line change @@ -8,9 +8,13 @@ const { parseJs } = require('./parseJs');
88module . exports = function parse ( css , opts ) {
99 let inputCode = typeof css === 'string' ? css : css . toString ( ) ;
1010
11+ let options = opts ?? { } ;
12+
13+ options . document = inputCode ;
14+
1115 let document = new postcss . Document ( {
1216 source : {
13- input : new postcss . Input ( inputCode , opts ) ,
17+ input : new postcss . Input ( inputCode , options ) ,
1418 start : { offset : 0 , line : 1 , column : 1 } ,
1519 } ,
1620 } ) ;
@@ -27,7 +31,7 @@ module.exports = function parse(css, opts) {
2731 /** @type {postcss.Root } */
2832 let parsedNode ;
2933
30- let input = new postcss . Input ( node . css , opts ) ;
34+ let input = new postcss . Input ( node . css , options ) ;
3135
3236 let interpolationsRanges = node . interpolationRanges . map ( ( range ) => {
3337 return {
You can’t perform that action at this time.
0 commit comments