Bug Tracker

Changes between Version 23 and Version 24 of Ticket #6485


Ignore:
Timestamp:
Jun 14, 2011, 2:21:09 PM (12 years ago)
Author:
paul.irish
Comment:

Started looking at the code around this and I'm gonna leave my notes, in case they can help someone else...

Talked with jdbarlett about this at TXJS and we agreed the shiv'ing approach within Shimprove http://www.iecss.com/shimprove/ is probably a better choice here. Well, actually the pastie jon linked in this issue's description has that code in a more readable format.

Essentially, that approach is this:

var frag = document.createDocumentFragment();
frag.createElement('abbr');
frag.createElement('aside');
// etc, ...

// fragment can now accept unknown element nodes

It looks like we'll want test coverage for:

  • html() when using the innerHTML shortcut fast path
  • clone()
  • append/prepend/before/after/replaceWith and appendto/prependto/insertbefore/insertafter/replaceAll and wrap/wrapInner/wrapAll ... all use domManip so really only a single code path there should be sufficient.

Implementation notes:

  • Appears as though everything is within manipulation.js
  • buildFragment() is used by domManip and looks to be the right place to improve things
  • a docFrag is made before sending it off to jQuery.clean() along with the html string. We could shiv it before clean or maybe within clean
  • We'll probably want a test in $.support to know if a browser collapses unknown elems. The test used in Modernizr would work well.

Open questions:

  • regex to test against incoming html? (or some indexOf magic?)
  • There is an innerHTML set action inside of clean(). Does that collapse unknown elements, or no, since it's still off-dom?

Legend:

Unmodified
Added
Removed
Modified