make the style-loader throw an exception in a non-browser environment

The intend of the style-loader is to apply styles
to the current environment. There is only appropriate
behavior defined for browser-like environments.
Other environments are not supported and an appropriate
loader for that environment should be used instead!

#6
master
Tobias Koppers 2014-03-01 17:29:38 +01:00
parent a984af8297
commit 0d5089b5f6
2 changed files with 8 additions and 2 deletions

View File

@ -2,7 +2,10 @@
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
module.exports = function(cssCode) {
module.exports = function addStyle(cssCode) {
if(typeof DEBUG !== "undefined" && DEBUG) {
if(typeof document !== "object") throw new Error("The style-loader cannot be used in a non-browser environment");
}
var styleElement = document.createElement("style");
styleElement.type = "text/css";
if (styleElement.styleSheet) {

View File

@ -2,7 +2,10 @@
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
module.exports = function(cssUrl) {
module.exports = function addStyleUrl(cssUrl) {
if(typeof DEBUG !== "undefined" && DEBUG) {
if(typeof document !== "object") throw new Error("The style-loader cannot be used in a non-browser environment");
}
var styleElement = document.createElement("link");
styleElement.rel = "stylesheet";
styleElement.type = "text/css";