[whatwg] HTML tree construction, inserting a foreign element, and foster parenting

Nolan Waite nolan at nolanw.ca
Sat Jul 20 17:23:20 PDT 2013


Hello! I've a question about the HTML spec. Suppose I'm parsing the following markup:

<table><math>

My question is: when I insert an element for the start tag token named "math", is it affected by the foster parenting logic?

To explain further, I get confused during tree construction when I reach the start tag token named "math".

I'm told in http://www.whatwg.org/specs/web-apps/current-work/multipage/tree-construction.html#parsing-main-inbody to "insert a foreign element for the token". However, at http://www.whatwg.org/specs/web-apps/current-work/multipage/tree-construction.html#insert-a-foreign-element it's pointed out that "the insert a foreign element algorithm isn't affected by the foster parenting logic". It continues, apparently by way of explanation, that "the current node, when the insert a foreign element algorithm is invoked, is always itself a non-HTML element".

Except that, in this case, the current node is the HTML "table" element. So this note confuses me, even though I realize it's probably non-normative.

Which partial tree is correct here? Is it

body
    table
        math

or is it

body
    math
    table

(I asked this question on IRC, but I'm not really an IRC person and thought this a better venue.)


More information about the whatwg mailing list