JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
namespace tweaks, fix <table><input>
authorJason Woofenden <jason@jasonwoof.com>
Wed, 23 Dec 2015 19:18:51 +0000 (14:18 -0500)
committerJason Woofenden <jason@jasonwoof.com>
Wed, 23 Dec 2015 19:18:51 +0000 (14:18 -0500)
parse-html.coffee

index 31a46f4..55d73a3 100644 (file)
@@ -1191,7 +1191,7 @@ parse_html = (txt, parse_error_cb = null) ->
                                last_template = null
                                last_template_i = null
                                for el, i in open_els
-                                       if el.name is 'template'
+                                       if el.name is 'template' and el.namespace is NS_HTML
                                                last_template = el
                                                last_template_i = i
                                                break
@@ -1200,7 +1200,7 @@ parse_html = (txt, parse_error_cb = null) ->
                                last_table = null
                                last_table_i
                                for el, i in open_els
-                                       if el.name is 'table'
+                                       if el.name is 'table' and el.namespace is NS_HTML
                                                last_table = el
                                                last_table_i = i
                                                break
@@ -1222,6 +1222,7 @@ parse_html = (txt, parse_error_cb = null) ->
                                        # this is odd
                                        target = open_els[open_els.length - 1]
                                        target_i = target.children.length
+                                       break
                                # 5. If last table has a parent element, then let adjusted
                                # insertion location be inside last table's parent element,
                                # immediately before last table, and abort these substeps.
@@ -2100,19 +2101,6 @@ parse_html = (txt, parse_error_cb = null) ->
                        return
                return
 
-       ins_mode_in_table_else = (t) ->
-               parse_error()
-               flag_foster_parenting = true # FIXME
-               ins_mode_in_body t
-               flag_foster_parenting = false
-       can_in_table = { # FIXME do this inline like everywhere else
-               'table': true
-               'tbody': true
-               'tfoot': true
-               'thead': true
-               'tr': true
-       }
-
        # 8.2.5.4.8 http://www.w3.org/TR/html5/syntax.html#parsing-main-incdata
        ins_mode_text = (t) ->
                if t.type is TYPE_TEXT
@@ -2142,6 +2130,19 @@ parse_html = (txt, parse_error_cb = null) ->
        # http://www.w3.org/TR/html5/syntax.html#tokenization
 
        # 8.2.5.4.9 http://www.w3.org/TR/html5/syntax.html#parsing-main-intable
+       ins_mode_in_table_else = (t) ->
+               parse_error()
+               flag_foster_parenting = true
+               ins_mode_in_body t
+               flag_foster_parenting = false
+               return
+       can_in_table = { # FIXME do this inline like everywhere else
+               'table': true
+               'tbody': true
+               'tfoot': true
+               'thead': true
+               'tr': true
+       }
        ins_mode_in_table = (t) ->
                switch t.type
                        when TYPE_TEXT
@@ -2192,7 +2193,7 @@ parse_html = (txt, parse_error_cb = null) ->
                                        when 'style', 'script', 'template'
                                                ins_mode_in_head t
                                        when 'input'
-                                               if is_input_hidden_tok t
+                                               unless is_input_hidden_tok t
                                                        ins_mode_in_table_else t
                                                else
                                                        parse_error()