- From: Yehuda Katz <wycats@gmail.com>
- Date: Thu, 10 Nov 2011 13:05:31 +0100
- To: Henri Sivonen <hsivonen@iki.fi>
- Cc: public-webapps WG <public-webapps@w3.org>
- Message-ID: <CAMFeDTV-xLtDgzt74kjE_8-HBFUihuyM5w+kjwj4dtpim+sczA@mail.gmail.com>
My thinking on this has evolved a bit since my original post. I wrote a patch to the spec that creates a new "unknown context" insertion mode that, in fact, only affects the problematic table case, and otherwise delegates to the in-body insertion mode. You can see it in full glory at http://www.w3.org/Bugs/Public/show_bug.cgi?id=14694 Please let me know if that doesn't clear it up for you :) -- Yehuda On Thursday, November 10, 2011, Henri Sivonen wrote: > On Fri, Nov 4, 2011 at 1:03 AM, Yehuda Katz <wycats@gmail.com<javascript:;>> > wrote: > > It would be useful if there was a way to take a String of HTML and parse > it > > into a document fragment. This should work even if the HTML string > contains > > elements that are invalid in the "in body" insertion mode. > > Something like this code should work: > > var frag = document.createDocumentFragment(); > > frag.innerHTML = "<tr><td>hello</td></tr>" > > someTable.appendChild(frag) > > It's easy for me to believe that there are valid use cases where the > first tag encountered is <tr>. > > > This would probably require a new, laxer insertion mode, which would > behave > > similarly to the body insertion mode, but with different semantics in > the "A > > start tag whose tag name is one of: "caption", "col", "colgroup", > "frame", > > "head", "tbody", "td", "tfoot", "th", "thead", "tr"" case. > > What are the use cases for having this work with <head> and <frame> as > first-level tags in the string? Do you also want it work with <html>, > <body> and <frameset>? > > What about SVG and MathML elements? > > I totally sympathize that this is a problem with <tr>, but developing > a complete solution that works sensibly even when you do stuff like > frag.innerHTML = "<head></head>" > frag.innerHTML = "<head><div></div></head>" > frag.innerHTML = "<frameset></frameset>a<!-- b -->" > frag.innerHTML = "<html><body>foo</html>bar<tr></tr>" > frag.innerHTML = "<html><body>foo</html><tr></tr>" > frag.innerHTML = "<div></div><tr></tr>" > frag.innerHTML = "<tr></tr><div></div>" > frag.innerHTML = "<g><path/></g>" > is a much trickier problem than you <tr> example makes it first seem. > > Do you have use cases for tags other than <tr> appearing as the outermost > tag? > > What would you expect the my examples above to do and why? > > -- > Henri Sivonen > hsivonen@iki.fi <javascript:;> > http://hsivonen.iki.fi/ > > -- Yehuda Katz (ph) 718.877.1325
Received on Thursday, 10 November 2011 12:06:08 UTC