diff --git a/index.js b/index.js index 9eff4a3..4d94643 100644 --- a/index.js +++ b/index.js @@ -145,7 +145,7 @@ function cssnext(string, options) { if (options.import !== false) { postcssInstance.use(require("postcss-import")( typeof options.import === "object" - ? options.import + ? assign({}, options.import) : undefined ) ) @@ -155,7 +155,7 @@ function cssnext(string, options) { if (options.url !== false) { postcssInstance.use(require("postcss-url")( typeof options.url === "object" - ? options.url + ? assign({}, options.url) : undefined ) ) @@ -186,7 +186,7 @@ function cssnext(string, options) { ) { postcssInstance.use(cssnext.features[key]( typeof features[key] === "object" - ? features[key] + ? assign({}, features[key]) : undefined ) ) @@ -201,7 +201,7 @@ function cssnext(string, options) { assign( {}, typeof options.compress === "object" - ? options.compress + ? assign({}, options.compress) : {}, // forced calc options to false // since we already used it diff --git a/test/option.import.js b/test/option.import.js index fdaea78..07d08ed 100644 --- a/test/option.import.js +++ b/test/option.import.js @@ -14,6 +14,9 @@ test("cssnext import option", function(t) { options: utils.readFixture("import.options.expected").trim(), } var opts = {from: "test/fixtures/here"} + function transformFn(c) { + return c + "\n new {}" + } t.equal( cssnext(input, opts).trim(), expected.default, @@ -23,9 +26,7 @@ test("cssnext import option", function(t) { cssnext(input, { from: opts.from, import: { - transform: function(c) { - return c + "\n new {}" - }, + transform: transformFn, }, }).trim(), expected.options, @@ -36,6 +37,18 @@ test("cssnext import option", function(t) { expected.default, "should be able to import even as a postcss plugin" ) - + var importOpt = { + transform: transformFn, + } + Object.freeze(importOpt) + t.doesNotThrow(function() { + cssnext(input, { + from: opts.from, + import: importOpt, + }).trim() + }, + expected.options, + "should not use original object as option" + ) t.end() })