File tree 1 file changed +10
-3
lines changed
1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -6,9 +6,9 @@ module.exports = function addStyle(cssCode) {
6
6
if ( typeof DEBUG !== "undefined" && DEBUG ) {
7
7
if ( typeof document !== "object" ) throw new Error ( "The style-loader cannot be used in a non-browser environment" ) ;
8
8
}
9
- var styleElement = document . createElement ( "style" ) ;
9
+ var styleElement = document . createElement ( "style" ) ,
10
+ head = document . head || document . getElementsByTagName ( "head" ) [ 0 ] ;
10
11
styleElement . type = "text/css" ;
11
- var head = document . getElementsByTagName ( "head" ) [ 0 ] ;
12
12
head . appendChild ( styleElement ) ;
13
13
if ( styleElement . styleSheet ) {
14
14
styleElement . styleSheet . cssText = cssCode ;
@@ -24,8 +24,15 @@ module.exports = function addStyle(cssCode) {
24
24
styleElement . childNodes [ 0 ] . nodeValue = cssCode ;
25
25
}
26
26
} else {
27
- head . removeChild ( styleElement ) ;
27
+ dispose ( ) ;
28
28
}
29
29
} ;
30
+ } else {
31
+ // For the useable API, provide a function to remove the stylesheet.
32
+ return dispose ;
33
+ }
34
+
35
+ function dispose ( ) {
36
+ head . removeChild ( styleElement ) ;
30
37
}
31
38
} ;
You can’t perform that action at this time.
0 commit comments