@@ -71,7 +71,7 @@ def __init__(self, strict = False, tree=simpletree.TreeBuilder,
7171"inRow" :InRowPhase (self ,self .tree ),
7272"inCell" :InCellPhase (self ,self .tree ),
7373"inSelect" :InSelectPhase (self ,self .tree ),
74- # XXX inSelectInTable
74+ "inSelectInTable" : InSelectInTablePhase ( self , self . tree ),
7575"afterBody" :AfterBodyPhase (self ,self .tree ),
7676"inFrameset" :InFramesetPhase (self ,self .tree ),
7777"afterFrameset" :AfterFramesetPhase (self ,self .tree ),
@@ -977,7 +977,14 @@ def startTagCdata(self, name, attributes):
977977def startTagSelect (self ,name ,attributes ):
978978self .tree .reconstructActiveFormattingElements ()
979979self .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" ]
981988
982989def startTagMisplaced (self ,name ,attributes ):
983990""" Elements that should be children of other elements that have a
@@ -1876,6 +1883,41 @@ def endTagOther(self, name):
18761883 {"name" :name })
18771884
18781885
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+
18791921class AfterBodyPhase (Phase ):
18801922def __init__ (self ,parser ,tree ):
18811923Phase .__init__ (self ,parser ,tree )