This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.
To be reflect the prior consensus (on public-webapps) about implied context parsing. The basic idea is this: While parsing children of the template element, act as if IN_HEAD, but append any produced nodes to the template element's content. When the first "determining" start tag is encountered, set the context element based on the indentity of that tag, reset the insertion mode appropriately and continue. Non-determining start tags must include: template, style, script, link.
We'll also need an explicit clause for non-whitespace text (else we'll end up implying a closing HEAD tag). Basically this clause will add non-whitespace text to the DOM without exiting implied context parsing (so we'll keep searching for a "determining" start tag afterward).
http://dvcs.w3.org/hg/webcomponents/rev/557c7e693458
I implemented the current spec text (including "clear the stack back to XXX", and I have some questions: Here are html5lib test cases that illustrate the issues: // Does naked template go into <head> or <body> -- as is, it goes into <head> #data <template>Hello</template> #errors #document | <html> | <head> | <body> | <template> | "Hello" // Can template exist as a child of <html> -- as is, it gets put into <head> #data <html><template><div> #errors #document | <html> | <template> | <div> // Can template exist as a child of <colgroup> -- as is, no #data <table><colgroup><template>Hello #errors #document | <html> | <head> | <body> | <table> | <colgroup> | <template> | "Hello" // Can template exist as a child of <frameset> -- as is, no #data <frameset><template><frame> #errors #document | <html> | <head> | <body> | <frameset> | <template> | <frame> // Reset insertion mode picks InBody for </head>, which is wrong for this case. -- as is, this actually hits a series of assertions, and I'm pretty sure it's wrong. #data <head><template><div></div></template></head> #errors #document | <html> | <head> | <template> | <div> // Should "in cell" be modified to "close the cell" on </template> (e.g. with </table>, </tbody>, </tfoot>, </thead>, </tr>) -- as is, </tr> wil lbe ignored and <div> appended to <td> #data <body><template><td></tr><div></template> #errors #document | <html> | <head> | <body> | <template> | <td> | <div>
Also, just to make sure this is what we want: #data <body><template><tr><div></div></tr></template> #errors #document | <html> | <head> | <body> | <template> | <tr> | <div> Note that the div is foster parented *after* the <tr>, not before.
Likewise this one: #data <body><template><div><tr></tr></div></template> #errors #document | <html> | <head> | <body> | <template> | <div> (throws away the <tr> -- which I think makes sense).
Decisions: On Thu, Aug 30, 2012 at 10:52 AM, Rafael Weinstein <rafaelw@google.com> wrote: > // Does naked template go into <head> or <body> -- as is, it goes into <head> > #data > <template>Hello</template> > #errors > #document > | <html> > | <head> > | <body> > | <template> > | "Hello" This is correct (analog is <script>) > > // Can template exist as a child of <html> -- as is, it gets put into <head> > #data > <html><template><div> > #errors > #document > | <html> > | <template> > | <div> > This is correct (analog is <script>) > // Can template exist as a child of <colgroup> -- as is, no > #data > <table><colgroup><template>Hello > #errors > #document > | <html> > | <head> > | <body> > | <table> > | <colgroup> > | <template> > | "Hello" We need parser edits for this. Relevant test which should pass is // Can template exist as a child of <colgroup> -- as is, no #data <table><colgroup><template><col> #errors #document | <html> | <head> | <body> | <table> | <colgroup> | <template> | <col> > > // Can template exist as a child of <frameset> -- as is, no > #data > <frameset><template><frame> > #errors > #document > | <html> > | <head> > | <body> > | <frameset> > | <template> > | <frame> We need parser edits for this. Relevant test which should pass is #data <frameset><template><frame> #errors #document | <html> | <head> | <frameset> | <template> | <frame> > > // Reset insertion mode picks InBody for </head>, which is wrong for this case. > -- as is, this actually hits a series of assertions, and I'm pretty sure it's > wrong. > #data > <head><template><div></div></template></head> > #errors > #document > | <html> > | <head> > | <template> > | <div> Step 11 of reset insertion mode appropriately should be: If node is a head element and node is the context element, then switch the insertion mode to "in body" ("in body"! not "in head"!) and abort these steps. (fragment case) otherwise, switch the insertion mode to "in head" and abort these steps. > > // Should "in cell" be modified to "close the cell" on </template> (e.g. with > </table>, </tbody>, </tfoot>, </thead>, </tr>) -- as is, </tr> wil lbe ignored > and <div> appended to <td> > #data > <body><template><td></tr><div></template> > #errors > #document > | <html> > | <head> > | <body> > | <template> > | <td> > | <div> This is correct, but we need spec text that http://dev.w3.org/html5/spec/parsing.html#has-an-element-in-table-scope includes <template> > > Also, just to make sure this is what we want: > > #data > <body><template><tr><div></div></tr></template> > #errors > #document > | <html> > | <head> > | <body> > | <template> > | <tr> > | <div> > > Note that the div is foster parented *after* the <tr>, not before. Correct behavior. > > Likewise this one: > > #data > <body><template><div><tr></tr></div></template> > #errors > #document > | <html> > | <head> > | <body> > | <template> > | <div> > > (throws away the <tr> -- which I think makes sense). Correct behavior.
http://dvcs.w3.org/hg/webcomponents/rev/6b0813f30f10
For the colgroup case to work (e.g.: #data <table><colgroup><template><col> #errors #document | <html> | <head> | <body> | <table> | <colgroup> | <template> | <col> ), template contents mode needs to set the insertion mode to in column group when a col tag is encountered.
For the frameset case to work, template contents mode needs to set the insertion mode to in frameset when a frame tag is encountered.
The in head edit to reset insertion mode should read: Modify the step which begins "If node is a head element..." to be: If node is a head element and node is the context element, then switch the insertion mode to "in body" ("in body"! not "in head") and abort these steps (fragment case). Otherwise, switch the insertion mode to "in head", and abort these steps.
To clarify > // Should "in cell" be modified to "close the cell" on </template> (e.g. with > </table>, </tbody>, </tfoot>, </thead>, </tr>) -- as is, </tr> wil lbe ignored > and <div> appended to <td> > #data > <body><template><td></tr><div></template> > #errors > #document > | <html> > | <head> > | <body> > | <template> > | <td> > | <div> This is correct, but we need spec text that http://dev.w3.org/html5/spec/parsing.html#has-an-element-in-table-scope includes <template> Should actually be: #data <body><template><td></tr><div></template> #errors #document | <html> | <head> | <body> | <template> | <td> | <div>
also, it's probably worth clarifying for in cell mode: An end tag whose tag name is one of: "table", "tbody", "tfoot", "thead", "tr" If the stack of open elements does not have an element in table scope with the same tag name as that of the token (which can only happen for "tbody", "tfoot" and "thead", or in the fragment case), then this is a parse error and the token must be ignored. Otherwise, close the cell (see below) and reprocess the current token. --- That this can now happen if a template contents is currently being parsed (webkit was hitting an assertion which I had to relax by checking if templateTag is in tableScope.
note that i have patch for these edits which I'll submit as soon as I gain write access.
http://dvcs.w3.org/hg/webcomponents/rev/923f79e27d75