Skip to content
This repository was archived by the owner on Dec 19, 2024. It is now read-only.

Commit 4a6b09b

Browse files
committed
use object assign when passing options to atImport plugin
1 parent 513e9cd commit 4a6b09b

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ function cssnext(string, options) {
145145
if (options.import !== false) {
146146
postcssInstance.use(require("postcss-import")(
147147
typeof options.import === "object"
148-
? options.import
148+
? assign({}, options.import)
149149
: undefined
150150
)
151151
)

test/option.import.js

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ test("cssnext import option", function(t) {
1414
options: utils.readFixture("import.options.expected").trim(),
1515
}
1616
var opts = {from: "test/fixtures/here"}
17+
function transformFn(c) {
18+
return c + "\n new {}"
19+
}
1720
t.equal(
1821
cssnext(input, opts).trim(),
1922
expected.default,
@@ -23,9 +26,7 @@ test("cssnext import option", function(t) {
2326
cssnext(input, {
2427
from: opts.from,
2528
import: {
26-
transform: function(c) {
27-
return c + "\n new {}"
28-
},
29+
transform: transformFn,
2930
},
3031
}).trim(),
3132
expected.options,
@@ -36,6 +37,18 @@ test("cssnext import option", function(t) {
3637
expected.default,
3738
"should be able to import even as a postcss plugin"
3839
)
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+
)
4053
t.end()
4154
})

0 commit comments

Comments
 (0)