#1487 new
Victor

Performance in ANY_INNERHTML_BUGGY feature tests

Reported by Victor | December 4th, 2012 @ 02:48 PM

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 <link /> 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();

Comments and changes to this ticket

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

The Prototype JavaScript library.

Shared Ticket Bins

People watching this ticket

Pages