Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
improved append / insert
  • Loading branch information
scottjehl committed Feb 17, 2011
1 parent 6ed7c17 commit 1ec47b9
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions respond.src.js
Expand Up @@ -88,9 +88,10 @@
//enable/disable styles
applyMedia = function( fromResize ){
var name = "clientWidth",
docElemProp = docElem[ name ]
docElemProp = docElem[ name ],
currWidth = doc.compatMode === "CSS1Compat" && docElemProp || doc.body[ name ] || docElemProp,
styleBlocks = {},
lastLink = links[ links.length-1 ],
now = (new Date()).getTime();

//throttle resize calls
Expand Down Expand Up @@ -126,8 +127,9 @@
//inject active styles, grouped by media type
for( var i in styleBlocks ){
var ss = doc.createElement( "style" ),
css = styleBlocks[ i ].join("");

css = styleBlocks[ i ].join( "" );

ss.type = "text/css";
ss.media = i;

if ( ss.styleSheet ){
Expand All @@ -136,8 +138,8 @@
else {
ss.appendChild( doc.createTextNode( css ) );
}
head.appendChild( ss );
head.insertBefore( ss, ( appendedEls.length ? appendedEls[appendedEls.length-1] : lastLink ).nextSibling );
appendedEls.push( ss );
}
},
Expand Down

0 comments on commit 1ec47b9

Please sign in to comment.