Merge branch 'master' of https://github.com/elsbree/style-loader into elsbree-master

master
Tobias Koppers 2015-10-19 20:26:49 +02:00
commit 8699f48b13
1 changed files with 9 additions and 2 deletions

View File

@ -17,7 +17,8 @@ var stylesInDom = {},
return document.head || document.getElementsByTagName("head")[0];
}),
singletonElement = null,
singletonCounter = 0;
singletonCounter = 0,
styleElementsInsertedAtTop = [];
module.exports = function(list, options) {
if(typeof DEBUG !== "undefined" && DEBUG) {
@ -101,9 +102,15 @@ function listToStyles(list) {
function createStyleElement(options) {
var styleElement = document.createElement("style");
var head = getHeadElement();
var lastStyleElementInsertedAtTop = styleElementsInsertedAtTop[styleElementsInsertedAtTop.length - 1];
styleElement.type = "text/css";
if (options.insertAt === "top") {
head.insertBefore(styleElement, head.firstChild);
if(lastStyleElementInsertedAtTop) {
head.insertBefore(styleElement, lastStyleElementInsertedAtTop.nextSibling);
} else {
head.insertBefore(styleElement, head.firstChild);
}
styleElementsInsertedAtTop.push(styleElement);
} else if (options.insertAt === "bottom") {
head.appendChild(styleElement);
} else {