From 499d3c2893f6a79b7e529a1e06674225e6c53a04 Mon Sep 17 00:00:00 2001 From: Benjamin Amelot Date: Tue, 17 Apr 2018 11:15:55 +0200 Subject: [PATCH 1/2] feat: enable tag type configuration --- lib/addStyles.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/addStyles.js b/lib/addStyles.js index b7b07749..c0767b01 100644 --- a/lib/addStyles.js +++ b/lib/addStyles.js @@ -201,7 +201,9 @@ function removeStyleElement (style) { function createStyleElement (options) { var style = document.createElement("style"); - options.attrs.type = "text/css"; + if(options.attrs.type === undefined) { + options.attrs.type = "text/css"; + } addAttrs(style, options.attrs); insertStyleElement(options, style); @@ -212,7 +214,9 @@ function createStyleElement (options) { function createLinkElement (options) { var link = document.createElement("link"); - options.attrs.type = "text/css"; + if(options.attrs.type === undefined) { + options.attrs.type = "text/css"; + } options.attrs.rel = "stylesheet"; addAttrs(link, options.attrs); From 752223b047246b622b0eb3f8bc83d659decbfbc7 Mon Sep 17 00:00:00 2001 From: Benjamin Amelot Date: Tue, 17 Apr 2018 11:33:14 +0200 Subject: [PATCH 2/2] feat: enable tag type configuration -- added tests --- test/basic.test.js | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/test/basic.test.js b/test/basic.test.js index 54c2bce9..3725e962 100644 --- a/test/basic.test.js +++ b/test/basic.test.js @@ -220,6 +220,26 @@ describe("basic tests", function() { runCompilerTest(expected, done); }); // it attrs + it("type attribute", function(done) { + // Setup + styleLoaderOptions.attrs = {type: 'text/less'}; + + fs.writeFileSync( + rootDir + "main.js", + [ + "var a = require('./style.css');" + ].join("\n") + ); + + // Run + let expected = [ + existingStyle, + `` + ].join("\n"); + + runCompilerTest(expected, done); + }); // it type attribute + it("url", function(done) { cssRule.use = [ { @@ -261,6 +281,28 @@ describe("basic tests", function() { runCompilerTest(expected, done); }); // it url with attrs + it("url with type attribute", function (done) { + cssRule.use = [ + { + loader: "style-loader/url", + options: { + attrs: { + type: 'text/less' + } + } + }, + "file-loader" + ]; + + // Run + let expected = [ + existingStyle, + '' + ].join("\n"); + + runCompilerTest(expected, done); + }); // it url with type attribute + it("useable", function(done) { cssRule.use = [ {