From b0187d670bba29df6d0f24de0c145239a699b72f Mon Sep 17 00:00:00 2001 From: Evilebot Tnawi Date: Tue, 30 Jul 2019 13:13:57 +0300 Subject: [PATCH] feat: remove type `text/css` from style and link element (#399) --- src/runtime/addStyleUrl.js | 1 - src/runtime/addStyles.js | 4 - .../attributes-option.test.js.snap | 12 +-- test/__snapshots__/base-option.test.js.snap | 2 +- test/__snapshots__/insert-option.test.js.snap | 18 ++-- test/__snapshots__/loader.test.js.snap | 18 ++-- .../singleton-option.test.js.snap | 10 +- .../sourceMap-option.test.js.snap | 8 +- .../__snapshots__/addStyle.test.js.snap | 92 +++++++++---------- .../__snapshots__/addStyleUrl.test.js.snap | 4 +- 10 files changed, 82 insertions(+), 87 deletions(-) diff --git a/src/runtime/addStyleUrl.js b/src/runtime/addStyleUrl.js index fbe6f836..ec3ded8c 100644 --- a/src/runtime/addStyleUrl.js +++ b/src/runtime/addStyleUrl.js @@ -20,7 +20,6 @@ module.exports = function addStyleUrl(url, options) { const link = document.createElement('link'); link.rel = 'stylesheet'; - link.type = 'text/css'; link.href = url; Object.keys(options.attributes).forEach((key) => { diff --git a/src/runtime/addStyles.js b/src/runtime/addStyles.js index 1bb682fc..0737145b 100644 --- a/src/runtime/addStyles.js +++ b/src/runtime/addStyles.js @@ -194,10 +194,6 @@ function listToStyles(list, options) { function insertStyleElement(options) { var style = document.createElement('style'); - if (options.attributes.type === undefined) { - options.attributes.type = 'text/css'; - } - if (options.attributes.nonce === undefined) { var nonce = typeof __webpack_nonce__ !== 'undefined' ? __webpack_nonce__ : null; diff --git a/test/__snapshots__/attributes-option.test.js.snap b/test/__snapshots__/attributes-option.test.js.snap index 8ccae89e..903f757f 100644 --- a/test/__snapshots__/attributes-option.test.js.snap +++ b/test/__snapshots__/attributes-option.test.js.snap @@ -4,7 +4,7 @@ exports[`attributes option should add attributes to tag ("injectType" option is " style-loader test - +

Body

@@ -22,7 +22,7 @@ exports[`attributes option should add attributes to tag ("injectType" option is " style-loader test - @@ -43,7 +43,7 @@ exports[`attributes option should add attributes to tag ("injectType" option is " style-loader test - @@ -64,7 +64,7 @@ exports[`attributes option should add nonce attribute #2: DOM 1`] = ` " style-loader test - @@ -85,7 +85,7 @@ exports[`attributes option should add nonce attribute: DOM 1`] = ` " style-loader test - @@ -106,7 +106,7 @@ exports[`attributes option should override/add default type attribute to tag ("i " style-loader test - +

Body

diff --git a/test/__snapshots__/base-option.test.js.snap b/test/__snapshots__/base-option.test.js.snap index 22141d79..4345f9e7 100644 --- a/test/__snapshots__/base-option.test.js.snap +++ b/test/__snapshots__/base-option.test.js.snap @@ -4,7 +4,7 @@ exports[`base option should work: DOM 1`] = ` " style-loader test - diff --git a/test/__snapshots__/insert-option.test.js.snap b/test/__snapshots__/insert-option.test.js.snap index 9ac24d82..7e5d5b4a 100644 --- a/test/__snapshots__/insert-option.test.js.snap +++ b/test/__snapshots__/insert-option.test.js.snap @@ -3,7 +3,7 @@ exports[`insert option should insert styles before "#existing-style" id: DOM 1`] = ` " style-loader test - @@ -24,7 +24,7 @@ exports[`insert option should insert styles before "#existing-style" id: warning exports[`insert option should insert styles before exists styles: DOM 1`] = ` " style-loader test - @@ -46,7 +46,7 @@ exports[`insert option should insert styles in bottom when not specified: DOM 1` " style-loader test - @@ -67,7 +67,7 @@ exports[`insert option should insert styles in bottom when selector was not foun " style-loader test - @@ -88,7 +88,7 @@ exports[`insert option should insert styles in bottom: DOM 1`] = ` " style-loader test - @@ -116,7 +116,7 @@ exports[`insert option should insert styles in runtime created element: DOM 1`] -
" @@ -127,7 +127,7 @@ exports[`insert option should insert styles in runtime created element: errors 1 exports[`insert option should insert styles in runtime created element: warnings 1`] = `Array []`; exports[`insert option should insert styles in top: DOM 1`] = ` -" @@ -164,7 +164,7 @@ exports[`insert option should insert styles into target when target is iframe: D exports[`insert option should insert styles into target when target is iframe: errors 1`] = `Array []`; exports[`insert option should insert styles into target when target is iframe: iframe head 1`] = ` -"" @@ -179,7 +179,7 @@ exports[`insert option should insert styles into target: DOM 1`] = `

Body

-
diff --git a/test/__snapshots__/loader.test.js.snap b/test/__snapshots__/loader.test.js.snap index 3039623a..78bb530c 100644 --- a/test/__snapshots__/loader.test.js.snap +++ b/test/__snapshots__/loader.test.js.snap @@ -4,7 +4,7 @@ exports[`loader should work ("injectType" option is "linkTag"): DOM 1`] = ` " style-loader test - +

Body

@@ -22,7 +22,7 @@ exports[`loader should work ("injectType" option is "styleTag"): DOM 1`] = ` " style-loader test - @@ -43,7 +43,7 @@ exports[`loader should work ("injectType" option is "useableStyleTag"): DOM 1`] " style-loader test - @@ -64,7 +64,7 @@ exports[`loader should work for useable inject type and negative ref: DOM 1`] = " style-loader test - @@ -85,7 +85,7 @@ exports[`loader should work with css modules ("injectType" option is "linkTag"): " style-loader test - +

Body

@@ -103,10 +103,10 @@ exports[`loader should work with css modules ("injectType" option is "styleTag") " style-loader test - - - @@ -28,10 +28,10 @@ exports[`singleton option not specified: DOM 1`] = ` " style-loader test - @@ -52,7 +52,7 @@ exports[`singleton option true: DOM 1`] = ` " style-loader test - - @@ -25,7 +25,7 @@ exports[`sourceMap option not specified: DOM 1`] = ` " style-loader test - @@ -46,7 +46,7 @@ exports[`sourceMap option true, but previous loader do not generate source map: " style-loader test - @@ -67,7 +67,7 @@ exports[`sourceMap option true: DOM 1`] = ` " style-loader test -"`; +exports[`addStyle should insert style tag in iframe 2`] = `""`; exports[`addStyle should throw error with invalid "insertAt" option 1`] = ` "[Style Loader] @@ -17,103 +17,103 @@ exports[`addStyle should throw error with invalid "insertInto" option 1`] = `"'# exports[`addStyle should throw error with invalid "insertInto" option 2`] = `"Couldn't find a style target. This probably means that the value for the 'insertInto' parameter is invalid."`; -exports[`addStyle should work "insertAt" option and with children 1`] = `"Title

Hello world

"`; +exports[`addStyle should work "insertAt" option and with children 1`] = `"Title

Hello world

"`; -exports[`addStyle should work "insertAt" option and with children 2`] = `"Title

Hello world

"`; +exports[`addStyle should work "insertAt" option and with children 2`] = `"Title

Hello world

"`; -exports[`addStyle should work #2 1`] = `"Title

Hello world

"`; +exports[`addStyle should work #2 1`] = `"Title

Hello world

"`; -exports[`addStyle should work 1`] = `"Title

Hello world

"`; +exports[`addStyle should work 1`] = `"Title

Hello world

"`; -exports[`addStyle should work with "attributes" option #2 1`] = `"Title

Hello world

"`; +exports[`addStyle should work with "attributes" option #2 1`] = `"Title

Hello world

"`; -exports[`addStyle should work with "attributes" option 1`] = `"Title

Hello world

"`; +exports[`addStyle should work with "attributes" option 1`] = `"Title

Hello world

"`; -exports[`addStyle should work with "base" option 1`] = `"Title

Hello world

"`; +exports[`addStyle should work with "base" option 1`] = `"Title

Hello world

"`; -exports[`addStyle should work with "insertAt" option #2 1`] = `"Title

Hello world

"`; +exports[`addStyle should work with "insertAt" option #2 1`] = `"Title

Hello world

"`; -exports[`addStyle should work with "insertAt" option #3 1`] = `"Title

Hello world

"`; +exports[`addStyle should work with "insertAt" option #3 1`] = `"Title

Hello world

"`; -exports[`addStyle should work with "insertAt" option 1`] = `"Title

Hello world

"`; +exports[`addStyle should work with "insertAt" option 1`] = `"Title

Hello world

"`; -exports[`addStyle should work with "insertInto" option #2 1`] = `"Title

Hello world

"`; +exports[`addStyle should work with "insertInto" option #2 1`] = `"Title

Hello world

"`; -exports[`addStyle should work with "insertInto" option #3 1`] = `"Title

Hello world

"`; +exports[`addStyle should work with "insertInto" option #3 1`] = `"Title

Hello world

"`; -exports[`addStyle should work with "insertInto" option 1`] = `"Title

Hello world

"`; +exports[`addStyle should work with "insertInto" option 1`] = `"Title

Hello world

"`; exports[`addStyle should work with "sourceMap" option #2 1`] = ` -"Title

Hello world

" `; -exports[`addStyle should work with "sourceMap" option #3 1`] = `"Title

Hello world

"`; +exports[`addStyle should work with "sourceMap" option #3 1`] = `"Title

Hello world

"`; -exports[`addStyle should work with "sourceMap" option 1`] = `"Title

Hello world

"`; +exports[`addStyle should work with "sourceMap" option 1`] = `"Title

Hello world

"`; -exports[`addStyle should work with media 1`] = `"Title

Hello world

"`; +exports[`addStyle should work with media 1`] = `"Title

Hello world

"`; -exports[`addStyle should work with nonce 1`] = `"Title

Hello world

"`; +exports[`addStyle should work with nonce 1`] = `"Title

Hello world

"`; -exports[`addStyle should work with same module id in list 1`] = `"Title

Hello world

"`; +exports[`addStyle should work with same module id in list 1`] = `"Title

Hello world

"`; -exports[`addStyle should work with same module id in list 2`] = `"Title

Hello world

"`; +exports[`addStyle should work with same module id in list 2`] = `"Title

Hello world

"`; -exports[`addStyle should work with updates #2 1`] = `"Title

Hello world

"`; +exports[`addStyle should work with updates #2 1`] = `"Title

Hello world

"`; -exports[`addStyle should work with updates #2 2`] = `"Title

Hello world

"`; +exports[`addStyle should work with updates #2 2`] = `"Title

Hello world

"`; -exports[`addStyle should work with updates #3 1`] = `"Title

Hello world

"`; +exports[`addStyle should work with updates #3 1`] = `"Title

Hello world

"`; -exports[`addStyle should work with updates #3 2`] = `"Title

Hello world

"`; +exports[`addStyle should work with updates #3 2`] = `"Title

Hello world

"`; -exports[`addStyle should work with updates #5 1`] = `"Title

Hello world

"`; +exports[`addStyle should work with updates #5 1`] = `"Title

Hello world

"`; -exports[`addStyle should work with updates #5 2`] = `"Title

Hello world

"`; +exports[`addStyle should work with updates #5 2`] = `"Title

Hello world

"`; -exports[`addStyle should work with updates #6 1`] = `"Title

Hello world

"`; +exports[`addStyle should work with updates #6 1`] = `"Title

Hello world

"`; -exports[`addStyle should work with updates #6 2`] = `"Title

Hello world

"`; +exports[`addStyle should work with updates #6 2`] = `"Title

Hello world

"`; -exports[`addStyle should work with updates #7 1`] = `"Title

Hello world

"`; +exports[`addStyle should work with updates #7 1`] = `"Title

Hello world

"`; -exports[`addStyle should work with updates #7 2`] = `"Title

Hello world

"`; +exports[`addStyle should work with updates #7 2`] = `"Title

Hello world

"`; -exports[`addStyle should work with updates #8 1`] = `"Title

Hello world

"`; +exports[`addStyle should work with updates #8 1`] = `"Title

Hello world

"`; exports[`addStyle should work with updates #8 2`] = `"Title

Hello world

"`; -exports[`addStyle should work with updates #9 1`] = `"Title

Hello world

"`; +exports[`addStyle should work with updates #9 1`] = `"Title

Hello world

"`; -exports[`addStyle should work with updates #9 2`] = `"Title

Hello world

"`; +exports[`addStyle should work with updates #9 2`] = `"Title

Hello world

"`; exports[`addStyle should work with updates #9 3`] = `"Title

Hello world

"`; -exports[`addStyle should work with updates #10 1`] = `"Title

Hello world

"`; +exports[`addStyle should work with updates #10 1`] = `"Title

Hello world

"`; exports[`addStyle should work with updates #10 2`] = `"Title

Hello world

"`; -exports[`addStyle should work with updates #11 1`] = `"Title

Hello world

"`; +exports[`addStyle should work with updates #11 1`] = `"Title

Hello world

"`; exports[`addStyle should work with updates #11 2`] = `"Title

Hello world

"`; -exports[`addStyle should work with updates #12 1`] = `"Title

Hello world

"`; +exports[`addStyle should work with updates #12 1`] = `"Title

Hello world

"`; -exports[`addStyle should work with updates #12 2`] = `"Title

Hello world

"`; +exports[`addStyle should work with updates #12 2`] = `"Title

Hello world

"`; -exports[`addStyle should work with updates #13 1`] = `"Title

Hello world

"`; +exports[`addStyle should work with updates #13 1`] = `"Title

Hello world

"`; -exports[`addStyle should work with updates #13 2`] = `"Title

Hello world

"`; +exports[`addStyle should work with updates #13 2`] = `"Title

Hello world

"`; -exports[`addStyle should work with updates #14 1`] = `"Title

Hello world

"`; +exports[`addStyle should work with updates #14 1`] = `"Title

Hello world

"`; -exports[`addStyle should work with updates #14 2`] = `"Title

Hello world

"`; +exports[`addStyle should work with updates #14 2`] = `"Title

Hello world

"`; -exports[`addStyle should work with updates #15 1`] = `"Title

Hello world

"`; +exports[`addStyle should work with updates #15 1`] = `"Title

Hello world

"`; -exports[`addStyle should work with updates #15 2`] = `"Title

Hello world

"`; +exports[`addStyle should work with updates #15 2`] = `"Title

Hello world

"`; -exports[`addStyle should work with updates 1`] = `"Title

Hello world

"`; +exports[`addStyle should work with updates 1`] = `"Title

Hello world

"`; -exports[`addStyle should work with updates 2`] = `"Title

Hello world

"`; +exports[`addStyle should work with updates 2`] = `"Title

Hello world

"`; diff --git a/test/runtime/__snapshots__/addStyleUrl.test.js.snap b/test/runtime/__snapshots__/addStyleUrl.test.js.snap index fcb4131b..5f211572 100644 --- a/test/runtime/__snapshots__/addStyleUrl.test.js.snap +++ b/test/runtime/__snapshots__/addStyleUrl.test.js.snap @@ -1,5 +1,5 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`addStyle should work 1`] = `"Title

Hello world

"`; +exports[`addStyle should work 1`] = `"Title

Hello world

"`; -exports[`addStyle should work with "attributes" option 1`] = `"Title

Hello world

"`; +exports[`addStyle should work with "attributes" option 1`] = `"Title

Hello world

"`;