From d91ba9e2f9e081cfb53edeb2e73037257abab423 Mon Sep 17 00:00:00 2001 From: Rachel Fenichel Date: Tue, 8 Nov 2016 16:54:35 -0800 Subject: [PATCH 1/2] Move injected css to start of head --- core/css.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/core/css.js b/core/css.js index 32f47a6f0..7c42cff1a 100644 --- a/core/css.js +++ b/core/css.js @@ -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(/<<>>/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; From 34a6d5e6e4b91e3990e4281cd3aa1ef7d9be829a Mon Sep 17 00:00:00 2001 From: Rachel Fenichel Date: Wed, 9 Nov 2016 13:12:18 -0800 Subject: [PATCH 2/2] simplification --- core/css.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/core/css.js b/core/css.js index 7c42cff1a..bac0d628c 100644 --- a/core/css.js +++ b/core/css.js @@ -86,11 +86,7 @@ Blockly.Css.inject = function(hasCss, pathToMedia) { text = text.replace(/<<>>/g, Blockly.Css.mediaPath_); // Inject CSS tag at start of head. var cssNode = document.createElement('style'); - if (document.head.firstChild) { - document.head.insertBefore(cssNode, document.head.firstChild); - } else { - document.head.appendChild(cssNode); - } + document.head.insertBefore(cssNode, document.head.firstChild); var cssTextNode = document.createTextNode(text); cssNode.appendChild(cssTextNode);