File tree 2 files changed +11
-6
lines changed
src/html5lib/treebuilders
2 files changed +11
-6
lines changed Original file line number Diff line number Diff line change 1
- import warnings
2
1
from html5lib .constants import scopingElements , tableInsertModeElements , namespaces
3
2
try :
4
3
frozenset
@@ -115,7 +114,6 @@ def __init__(self, namespaceHTMLElements):
115
114
self .defaultNamespace = "http://www.w3.org/1999/xhtml"
116
115
else :
117
116
self .defaultNamespace = None
118
- warnings .warn (u"namespaceHTMLElements=False is currently rather broken, you probably don't want to use it" )
119
117
self .reset ()
120
118
121
119
def reset (self ):
Original file line number Diff line number Diff line change @@ -304,8 +304,7 @@ def insertRoot(self, token):
304
304
docStr += ' PUBLIC "%s" "%s"' % (self .doctype .publicId or "" ,
305
305
self .doctype .systemId or "" )
306
306
docStr += ">"
307
- #TODO - this needs to work when elements are not put into the default ns
308
- docStr += "<html xmlns='http://www.w3.org/1999/xhtml'></html>"
307
+ docStr += "<THIS_SHOULD_NEVER_APPEAR_PUBLICLY/>"
309
308
310
309
try :
311
310
root = etree .fromstring (docStr )
@@ -321,9 +320,17 @@ def insertRoot(self, token):
321
320
self .document = self .documentClass ()
322
321
self .document ._elementTree = root .getroottree ()
323
322
324
- #Add the root element to the internal child/open data structures
323
+ # Give the root element the right name
324
+ name = token ["name" ]
325
325
namespace = token .get ("namespace" , None )
326
- root_element = self .elementClass (token ["name" ], namespace )
326
+ if namespace is None :
327
+ etree_tag = name
328
+ else :
329
+ etree_tag = "{%s}%s" % (namespace , name )
330
+ root .tag = etree_tag
331
+
332
+ #Add the root element to the internal child/open data structures
333
+ root_element = self .elementClass (name , namespace )
327
334
root_element ._element = root
328
335
self .document ._childNodes .append (root_element )
329
336
self .openElements .append (root_element )
You can’t perform that action at this time.
0 commit comments