You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I noticed that the style-loader can crash IE 8 forcing it to close. I used the IE8 - XPvirtual machine from modern.ie (IE 8.0.6001.18702) to test an application that adds a stylesheet containing a @font-face declaration.
The problem seems to be that the cssCode is added to the styleElement before the styleElement is appended to head. Changing the order so that the styleElement is part of the DOM-tree when setting the cssCode fixes the crash:
Maybe this is caused by IE security checks (also see related issue) applied to @font-face, because adding other styles without @font-face works with the existing implementation.
Example
<!DOCTYPE html><html><head><metacharset="utf-8"/>
<metahttp-equiv="X-UA-Compatible" content="IE=edge"><title></title></head><body><scripttype="text/javascript">(function(){// webpack output with urls replacedvarcssCode="@font-face {\n font-family: \"Example\";\n src: url("+"Example.eot"+"#iefix) format(\"eot\"), url("+"Example.woff"+") format(\"woff\"), url("+"Example.otf"+") format(\"opentype\"); }"varotherCssCode="body{ background-color: red;}";// works// addStyle(otherCssCode);// addStyleFixed(otherCssCode);// crashesaddStyle(cssCode);// works// addStyleFixed(cssCode);functionaddStyle(cssCode){if(true){if(typeofdocument!=="object")thrownewError("The style-loader cannot be used in a non-browser environment");}varstyleElement=document.createElement("style");styleElement.type="text/css";if(styleElement.styleSheet){styleElement.styleSheet.cssText=cssCode;}else{styleElement.appendChild(document.createTextNode(cssCode));}varhead=document.getElementsByTagName("head")[0];head.appendChild(styleElement);returnfunction(){head.removeChild(styleElement);};}functionaddStyleFixed(cssCode){if(true){if(typeofdocument!=="object")thrownewError("The style-loader cannot be used in a non-browser environment");}varstyleElement=document.createElement("style");styleElement.type="text/css";varhead=document.getElementsByTagName("head")[0];head.appendChild(styleElement);if(styleElement.styleSheet){styleElement.styleSheet.cssText=cssCode;}else{styleElement.appendChild(document.createTextNode(cssCode));}returnfunction(){head.removeChild(styleElement);};}}());</script></body></html>
The text was updated successfully, but these errors were encountered:
Sorry for the late reply. I'm pressed for time at the moment. I hope I can get to do the pull request next week. If you are able to perform the change in the meantime I would appreciate that as well :)
I noticed that the style-loader can crash IE 8 forcing it to close. I used the IE8 - XP virtual machine from modern.ie (IE 8.0.6001.18702) to test an application that adds a stylesheet containing a
@font-face
declaration.The problem seems to be that the
cssCode
is added to thestyleElement
before thestyleElement
is appended tohead
. Changing the order so that thestyleElement
is part of the DOM-tree when setting thecssCode
fixes the crash:Maybe this is caused by IE security checks (also see related issue) applied to
@font-face
, because adding other styles without@font-face
works with the existing implementation.Example
The text was updated successfully, but these errors were encountered: