Skip to content

Commit

Permalink
reuse a global style element
Browse files Browse the repository at this point in the history
  • Loading branch information
imsky committed Jan 9, 2013
1 parent 9b88b5b commit 9982b53
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions holder.js
Expand Up @@ -326,12 +326,23 @@ app.run = function (o) {
preempted = true;

for (i = 0, l = imageNodes.length; i < l; i++) images.push(imageNodes[i]);

var holdercss = document.getElementById("holderjs-style");

if(!holdercss){
holdercss = document.createElement("style");
holdercss.setAttribute("id", "holderjs-style");
holdercss.type = "text/css";
document.getElementsByTagName("head")[0].appendChild(holdercss);
}

var holdercss = document.createElement("style");
holdercss.type = "text/css";
holdercss.styleSheet ? holdercss.styleSheet.cssText = options.stylesheet : holdercss.textContent = options.stylesheet;
document.getElementsByTagName("head")[0].appendChild(holdercss);

if(holdercss.styleSheet){
holdercss.styleSheet += options.stylesheet;
}
else{
holdercss.textContent+= options.stylesheet;
}

var cssregex = new RegExp(options.domain + "\/(.*?)\"?\\)");

for (var l = bgnodes.length, i = 0; i < l; i++) {
Expand Down

0 comments on commit 9982b53

Please sign in to comment.