diff --git a/src/browser/ui/dom/setInnerHTML.js b/src/browser/ui/dom/setInnerHTML.js
index a81caa437590..23da3071a01d 100644
--- a/src/browser/ui/dom/setInnerHTML.js
+++ b/src/browser/ui/dom/setInnerHTML.js
@@ -20,6 +20,9 @@
var ExecutionEnvironment = require('ExecutionEnvironment');
+var WHITESPACE_TEST = /^[ \r\n\t\f]/;
+var NONVISIBLE_TEST = /<(!--|link|noscript|meta|script|style)[ \r\n\t\f\/>]/;
+
/**
* Set the innerHTML property of a node, ensuring that whitespace is preserved
* even in IE8.
@@ -56,13 +59,8 @@ if (ExecutionEnvironment.canUseDOM) {
// thin air on IE8, this only happens if there is no visible text
// in-front of the non-visible tags. Piggyback on the whitespace fix
// and simply check if any non-visible tags appear in the source.
- if (html.match(/^[ \r\n\t\f]/) ||
- html[0] === '<' && (
- html.indexOf('