Move injected css to start of head

This commit is contained in:
Rachel Fenichel
2016-11-08 16:54:35 -08:00
parent 668b373434
commit d91ba9e2f9

View File

@@ -84,9 +84,14 @@ Blockly.Css.inject = function(hasCss, pathToMedia) {
// Strip off any trailing slash (either Unix or Windows).
Blockly.Css.mediaPath_ = pathToMedia.replace(/[\\\/]$/, '');
text = text.replace(/<<<PATH>>>/g, Blockly.Css.mediaPath_);
// Inject CSS tag.
// Inject CSS tag at start of head.
var cssNode = document.createElement('style');
document.head.appendChild(cssNode);
if (document.head.firstChild) {
document.head.insertBefore(cssNode, document.head.firstChild);
} else {
document.head.appendChild(cssNode);
}
var cssTextNode = document.createTextNode(text);
cssNode.appendChild(cssTextNode);
Blockly.Css.styleSheet_ = cssNode.sheet;