|
3 | 3 | XMLNode = require './XMLNode' |
4 | 4 | NodeType = require './NodeType' |
5 | 5 | XMLAttribute = require './XMLAttribute' |
| 6 | +XMLNamedNodeMap = require './XMLNamedNodeMap' |
6 | 7 |
|
7 | 8 | # Represents an element of the XML document |
8 | 9 | module.exports = class XMLElement extends XMLNode |
@@ -42,6 +43,19 @@ module.exports = class XMLElement extends XMLNode |
42 | 43 | Object.defineProperty @::, 'tagName', get: () -> @name |
43 | 44 |
|
44 | 45 |
|
| 46 | + # DOM level 4 |
| 47 | + Object.defineProperty @::, 'namespaceURI', get: () -> '' |
| 48 | + Object.defineProperty @::, 'prefix', get: () -> '' |
| 49 | + Object.defineProperty @::, 'localName', get: () -> @name |
| 50 | + Object.defineProperty @::, 'id', get: () -> throw new Error "This DOM method is not implemented." + @debugInfo() |
| 51 | + Object.defineProperty @::, 'className', get: () -> throw new Error "This DOM method is not implemented." + @debugInfo() |
| 52 | + Object.defineProperty @::, 'classList', get: () -> throw new Error "This DOM method is not implemented." + @debugInfo() |
| 53 | + Object.defineProperty @::, 'attributes', get: () -> |
| 54 | + if not @attributeMap or not @attributeMap.nodes |
| 55 | + @attributeMap = new XMLNamedNodeMap @attribs |
| 56 | + return @attributeMap |
| 57 | + |
| 58 | + |
45 | 59 | # Creates and returns a deep clone of `this` |
46 | 60 | # |
47 | 61 | clone: () -> |
@@ -143,3 +157,9 @@ module.exports = class XMLElement extends XMLNode |
143 | 157 | setIdAttribute: (name, isId) -> if @attribs.hasOwnProperty(name) then @attribs[name].isId else isId |
144 | 158 | setIdAttributeNS: (namespaceURI, localName, isId) -> throw new Error "This DOM method is not implemented." + @debugInfo() |
145 | 159 | setIdAttributeNode: (idAttr, isId) -> throw new Error "This DOM method is not implemented." + @debugInfo() |
| 160 | + |
| 161 | + |
| 162 | + # DOM Level 4 |
| 163 | + getElementsByTagName: (tagname) -> throw new Error "This DOM method is not implemented." + @debugInfo() |
| 164 | + getElementsByTagNameNS: (namespaceURI, localName) -> throw new Error "This DOM method is not implemented." + @debugInfo() |
| 165 | + getElementsByClassName: (classNames) -> throw new Error "This DOM method is not implemented." + @debugInfo() |
0 commit comments