@@ -71,7 +71,7 @@ def __init__(self, strict = False, tree=simpletree.TreeBuilder,
71
71
"inRow" : InRowPhase (self , self .tree ),
72
72
"inCell" : InCellPhase (self , self .tree ),
73
73
"inSelect" : InSelectPhase (self , self .tree ),
74
- # XXX inSelectInTable
74
+ "inSelectInTable" : InSelectInTablePhase ( self , self . tree ),
75
75
"afterBody" : AfterBodyPhase (self , self .tree ),
76
76
"inFrameset" : InFramesetPhase (self , self .tree ),
77
77
"afterFrameset" : AfterFramesetPhase (self , self .tree ),
@@ -977,7 +977,14 @@ def startTagCdata(self, name, attributes):
977
977
def startTagSelect (self , name , attributes ):
978
978
self .tree .reconstructActiveFormattingElements ()
979
979
self .tree .insertElement (name , attributes )
980
- self .parser .phase = self .parser .phases ["inSelect" ]
980
+ if self .parser .phase in (self .parser .phases ["inTable" ],
981
+ self .parser .phases ["inCaption" ],
982
+ self .parser .phases ["inColumnGroup" ],
983
+ self .parser .phases ["inTableBody" ], self .parser .phases ["inRow" ],
984
+ self .parser .phases ["inCell" ]):
985
+ self .parser .phase = self .parser .phases ["inSelectInTable" ]
986
+ else :
987
+ self .parser .phase = self .parser .phases ["inSelect" ]
981
988
982
989
def startTagMisplaced (self , name , attributes ):
983
990
""" Elements that should be children of other elements that have a
@@ -1876,6 +1883,41 @@ def endTagOther(self, name):
1876
1883
{"name" : name })
1877
1884
1878
1885
1886
+ class InSelectInTablePhase (Phase ):
1887
+ def __init__ (self , parser , tree ):
1888
+ Phase .__init__ (self , parser , tree )
1889
+
1890
+ self .startTagHandler = utils .MethodDispatcher ([
1891
+ (("caption" , "table" , "tbody" , "tfoot" , "thead" , "tr" , "td" , "th" ), self .startTagTable )
1892
+ ])
1893
+ self .startTagHandler .default = self .startTagOther
1894
+
1895
+ self .endTagHandler = utils .MethodDispatcher ([
1896
+ (("caption" , "table" , "tbody" , "tfoot" , "thead" , "tr" , "td" , "th" ), self .endTagTable )
1897
+ ])
1898
+ self .endTagHandler .default = self .endTagOther
1899
+
1900
+ def processCharacters (self , data ):
1901
+ self .parser .phases ["inSelect" ].processCharacters (data )
1902
+
1903
+ def startTagTable (self , name , attributes ):
1904
+ self .parser .parseError ("unexpected-table-element-start-tag-in-select-in-table" , {"name" : name })
1905
+ self .endTagOther ("select" )
1906
+ self .parser .phase .processStartTag (name , attributes )
1907
+
1908
+ def startTagOther (self , name , attributes ):
1909
+ self .parser .phases ["inSelect" ].processStartTag (name , attributes )
1910
+
1911
+ def endTagTable (self , name ):
1912
+ self .parser .parseError ("unexpected-table-element-end-tag-in-select-in-table" , {"name" : name })
1913
+ if self .tree .elementInScope (name ):
1914
+ self .endTagOther ("select" )
1915
+ self .parser .phase .processEndTag (name )
1916
+
1917
+ def endTagOther (self , name ):
1918
+ self .parser .phases ["inSelect" ].processEndTag (name )
1919
+
1920
+
1879
1921
class AfterBodyPhase (Phase ):
1880
1922
def __init__ (self , parser , tree ):
1881
1923
Phase .__init__ (self , parser , tree )
0 commit comments