Use Document.createElement and Document.createTextNode instead of dom.Element and dom.Text

[email protected]
Newsgroups gmane.comp.python.twisted.bugs
Message-ID <[email protected]>
New submission from exarkun <[email protected]>:

It seems several Python DOM libraries allow one to create elements and other nodes using normal Python classes and constructors.  This is tempting, since it is ''normal'', but it is basically wrong and, in some libraries, unintentional.  The DOM APIs for creating an element is actually the document object's `createElement` method; the API for creating a text node, the document object's `createTextNode` method.  In the case of text nodes, this API is sometimes even more convenient, as in the case of `xml.dom.minidom.Text`, which does not accept any arguments and requires an attribute to be set after creation.  The issue of correctness comes up when one encounter's functionality which relies on the ''owner document'' of a node.  Nodes created through a document method can be relied on to hav
 e the correct value for their `ownerDocument` attribute.  Nodes created using a Python class constructor directly cannot.

Lore seems to be the most significant offender in this area, but `twisted.web.domhelpers` also does this a bit.


----------
Type     : enhancement
Component: lore
Keywords : 
Priority : normal
Nosy     : 
----------
http://twistedmatrix.com/trac/ticket/3790
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.