This repository was archived by the owner on Dec 19, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +21
-8
lines changed Expand file tree Collapse file tree 2 files changed +21
-8
lines changed Original file line number Diff line number Diff line change @@ -145,7 +145,7 @@ function cssnext(string, options) {
145
145
if ( options . import !== false ) {
146
146
postcssInstance . use ( require ( "postcss-import" ) (
147
147
typeof options . import === "object"
148
- ? options . import
148
+ ? assign ( { } , options . import )
149
149
: undefined
150
150
)
151
151
)
@@ -155,7 +155,7 @@ function cssnext(string, options) {
155
155
if ( options . url !== false ) {
156
156
postcssInstance . use ( require ( "postcss-url" ) (
157
157
typeof options . url === "object"
158
- ? options . url
158
+ ? assign ( { } , options . url )
159
159
: undefined
160
160
)
161
161
)
@@ -186,7 +186,7 @@ function cssnext(string, options) {
186
186
) {
187
187
postcssInstance . use ( cssnext . features [ key ] (
188
188
typeof features [ key ] === "object"
189
- ? features [ key ]
189
+ ? assign ( { } , features [ key ] )
190
190
: undefined
191
191
)
192
192
)
@@ -201,7 +201,7 @@ function cssnext(string, options) {
201
201
assign (
202
202
{ } ,
203
203
typeof options . compress === "object"
204
- ? options . compress
204
+ ? assign ( { } , options . compress )
205
205
: { } ,
206
206
// forced calc options to false
207
207
// since we already used it
Original file line number Diff line number Diff line change @@ -14,6 +14,9 @@ test("cssnext import option", function(t) {
14
14
options : utils . readFixture ( "import.options.expected" ) . trim ( ) ,
15
15
}
16
16
var opts = { from : "test/fixtures/here" }
17
+ function transformFn ( c ) {
18
+ return c + "\n new {}"
19
+ }
17
20
t . equal (
18
21
cssnext ( input , opts ) . trim ( ) ,
19
22
expected . default ,
@@ -23,9 +26,7 @@ test("cssnext import option", function(t) {
23
26
cssnext ( input , {
24
27
from : opts . from ,
25
28
import : {
26
- transform : function ( c ) {
27
- return c + "\n new {}"
28
- } ,
29
+ transform : transformFn ,
29
30
} ,
30
31
} ) . trim ( ) ,
31
32
expected . options ,
@@ -36,6 +37,18 @@ test("cssnext import option", function(t) {
36
37
expected . default ,
37
38
"should be able to import even as a postcss plugin"
38
39
)
39
-
40
+ var importOpt = {
41
+ transform : transformFn ,
42
+ }
43
+ Object . freeze ( importOpt )
44
+ t . doesNotThrow ( function ( ) {
45
+ cssnext ( input , {
46
+ from : opts . from ,
47
+ import : importOpt ,
48
+ } ) . trim ( )
49
+ } ,
50
+ expected . options ,
51
+ "should not use original object as option"
52
+ )
40
53
t . end ( )
41
54
} )
You can’t perform that action at this time.
0 commit comments