File tree 2 files changed +48
-2
lines changed
2 files changed +48
-2
lines changed Original file line number Diff line number Diff line change @@ -201,7 +201,9 @@ function removeStyleElement (style) {
201
201
function createStyleElement ( options ) {
202
202
var style = document . createElement ( "style" ) ;
203
203
204
- options . attrs . type = "text/css" ;
204
+ if ( options . attrs . type === undefined ) {
205
+ options . attrs . type = "text/css" ;
206
+ }
205
207
206
208
addAttrs ( style , options . attrs ) ;
207
209
insertStyleElement ( options , style ) ;
@@ -212,7 +214,9 @@ function createStyleElement (options) {
212
214
function createLinkElement ( options ) {
213
215
var link = document . createElement ( "link" ) ;
214
216
215
- options . attrs . type = "text/css" ;
217
+ if ( options . attrs . type === undefined ) {
218
+ options . attrs . type = "text/css" ;
219
+ }
216
220
options . attrs . rel = "stylesheet" ;
217
221
218
222
addAttrs ( link , options . attrs ) ;
Original file line number Diff line number Diff line change @@ -220,6 +220,26 @@ describe("basic tests", function() {
220
220
runCompilerTest ( expected , done ) ;
221
221
} ) ; // it attrs
222
222
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
+
223
243
it ( "url" , function ( done ) {
224
244
cssRule . use = [
225
245
{
@@ -261,6 +281,28 @@ describe("basic tests", function() {
261
281
runCompilerTest ( expected , done ) ;
262
282
} ) ; // it url with attrs
263
283
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
+
264
306
it ( "useable" , function ( done ) {
265
307
cssRule . use = [
266
308
{
You can’t perform that action at this time.
0 commit comments