Avoid using overloaded native API's for DOMElement
michael opened this issue · comments
Michael Aufreiter commented
For instance in some places we use el.nodeType
which in our abstraction returns a string:
...
getNodeType() {
switch(this.el.nodeType) {
case window.Node.TEXT_NODE:
return "text"
case window.Node.ELEMENT_NODE:
return 'element'
case window.Node.DOCUMENT_NODE:
return 'document'
case window.Node.COMMENT_NODE:
return 'comment'
case window.Node.PROCESSING_INSTRUCTION_NODE:
return 'directive'
case window.Node.CDATA_SECTION_NODE:
return 'cdata'
default:
//
}
}
We should consider deprecating these problematic native API's and use explicit getters when possible.
E.g. el.isCdataElement()
then it is clear this is custom API with different semantics.
Michael Aufreiter commented
We may also want to use symbols for representing node types. E.g.
const { CDATA } = DOMElement.NodeTypes