File tree Expand file tree Collapse file tree 2 files changed +48
-2
lines changed Expand file tree Collapse file tree 2 files changed +48
-2
lines changed Original file line number Diff line number Diff line change @@ -201,7 +201,9 @@ function removeStyleElement (style) {
201201function createStyleElement ( options ) {
202202 var style = document . createElement ( "style" ) ;
203203
204- options . attrs . type = "text/css" ;
204+ if ( options . attrs . type === undefined ) {
205+ options . attrs . type = "text/css" ;
206+ }
205207
206208 addAttrs ( style , options . attrs ) ;
207209 insertStyleElement ( options , style ) ;
@@ -212,7 +214,9 @@ function createStyleElement (options) {
212214function createLinkElement ( options ) {
213215 var link = document . createElement ( "link" ) ;
214216
215- options . attrs . type = "text/css" ;
217+ if ( options . attrs . type === undefined ) {
218+ options . attrs . type = "text/css" ;
219+ }
216220 options . attrs . rel = "stylesheet" ;
217221
218222 addAttrs ( link , options . attrs ) ;
Original file line number Diff line number Diff line change @@ -220,6 +220,26 @@ describe("basic tests", function() {
220220 runCompilerTest ( expected , done ) ;
221221 } ) ; // it attrs
222222
223+ it ( "type attribute" , function ( done ) {
224+ // Setup
225+ styleLoaderOptions . attrs = { type : 'text/less' } ;
226+
227+ fs . writeFileSync (
228+ rootDir + "main.js" ,
229+ [
230+ "var a = require('./style.css');"
231+ ] . join ( "\n" )
232+ ) ;
233+
234+ // Run
235+ let expected = [
236+ existingStyle ,
237+ `<style type="${ styleLoaderOptions . attrs . type } ">${ requiredCss } </style>`
238+ ] . join ( "\n" ) ;
239+
240+ runCompilerTest ( expected , done ) ;
241+ } ) ; // it type attribute
242+
223243 it ( "url" , function ( done ) {
224244 cssRule . use = [
225245 {
@@ -261,6 +281,28 @@ describe("basic tests", function() {
261281 runCompilerTest ( expected , done ) ;
262282 } ) ; // it url with attrs
263283
284+ it ( "url with type attribute" , function ( done ) {
285+ cssRule . use = [
286+ {
287+ loader : "style-loader/url" ,
288+ options : {
289+ attrs : {
290+ type : 'text/less'
291+ }
292+ }
293+ } ,
294+ "file-loader"
295+ ] ;
296+
297+ // Run
298+ let expected = [
299+ existingStyle ,
300+ '<link rel="stylesheet" type="text/less" href="ec9d4f4f24028c3d51bf1e7728e632ff.css">'
301+ ] . join ( "\n" ) ;
302+
303+ runCompilerTest ( expected , done ) ;
304+ } ) ; // it url with type attribute
305+
264306 it ( "useable" , function ( done ) {
265307 cssRule . use = [
266308 {
You can’t perform that action at this time.
0 commit comments