[Bug 20130] [Templates]: <template> within <template> effectively resets the implied context

https://www.w3.org/Bugs/Public/show_bug.cgi?id=20130

--- Comment #1 from Rafael Weinstein <rafaelw@chromium.org> ---
After thinking more about this, I think it's worth adding a bit more logic to
the parser to ensure that, for any given parse, each template element has at
most one implied context. Here's the case which convinced me:

Consider the following, which seems totally reasonable:

#data
<body><template><thead></thead><tr></tr><tfoot></tfoot></template>
#errors
#document
| <html>
|   <head>
|   <body>
|     <template>
|       #document-fragment
|         <thead>
|         <tbody>
|           <tr>
|         <tfoot>

Now insert a template after the <thead>

#data
<body><template><thead></thead><template></template><tr></tr><tfoot></tfoot></template>
#errors
#document
| <html>
|   <head>
|   <body>
|     <template>
|       #document-fragment
|         <thead>
|         <template>
|           #document-fragment
|         <tr>

(i.e. because the implied element became <tbody> after the inner template was
popped, the <tfoot> got thrown away.

-----

I propose that the parser maintain a map of open template elements to implied
context tag. In Template Contents Mode, when the insertion mode gets set to
something else, the corresponding tagName is set as the implied context tag for
the template element. In resetInsertionModeAppropriately, if the current node
is a template tag and it has a mapped context tag already, use that to set the
insertion mode, otherwise set it to In Template Contents mode.

-- 
You are receiving this mail because:
You are the QA Contact for the bug.

Received on Wednesday, 5 December 2012 04:45:58 UTC