Open
Description
previous lighthouse ticket #1487
by Victor
Currently Prototype detects 3 innerHTML flaws: SELECT_ELEMENT_INNERHTML_BUGGY
, TABLE_ELEMENT_INNERHTML_BUGGY
, LINK_ELEMENT_INNERHTML_BUGGY
during page load. This requires HTML parsing in browser and slows page loading.
Check for TABLE_ELEMENT_INNERHTML_BUGGY
may be skipped when SELECT_ELEMENT_INNERHTML_BUGGY
is true, because they are used only in boolean expression.
Furthermore, LINK_ELEMENT_INNERHTML_BUGGY
may be skipped in the same way, until it is actually needed in update() when content contains tag.
These checks may be refactored to memoizing functions, allowing to invoke them directly where they are needed:
var SELECT_ELEMENT_INNERHTML_BUGGY = function() {
var el = document.createElement("select"), isBuggy = true;
el.innerHTML = "<option value=\"test\">test</option>";
if (el.options && el.options[0]) {
isBuggy = el.options[0].nodeName.toUpperCase() !== "OPTION";
}
el = null;
SELECT_ELEMENT_INNERHTML_BUGGY = isBuggy ? function() {return true} : function() {return false};
return isBuggy;
};
// skipped
var ANY_INNERHTML_BUGGY = SELECT_ELEMENT_INNERHTML_BUGGY() ||
TABLE_ELEMENT_INNERHTML_BUGGY() || LINK_ELEMENT_INNERHTML_BUGGY();