You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

XMLNamedNodeMap.js 1.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. // Generated by CoffeeScript 2.4.1
  2. (function() {
  3. // Represents a map of nodes accessed by a string key
  4. var XMLNamedNodeMap;
  5. module.exports = XMLNamedNodeMap = (function() {
  6. class XMLNamedNodeMap {
  7. // Initializes a new instance of `XMLNamedNodeMap`
  8. // This is just a wrapper around an ordinary
  9. // JS object.
  10. // `nodes` the object containing nodes.
  11. constructor(nodes) {
  12. this.nodes = nodes;
  13. }
  14. // Creates and returns a deep clone of `this`
  15. clone() {
  16. // this class should not be cloned since it wraps
  17. // around a given object. The calling function should check
  18. // whether the wrapped object is null and supply a new object
  19. // (from the clone).
  20. return this.nodes = null;
  21. }
  22. // DOM Level 1
  23. getNamedItem(name) {
  24. return this.nodes[name];
  25. }
  26. setNamedItem(node) {
  27. var oldNode;
  28. oldNode = this.nodes[node.nodeName];
  29. this.nodes[node.nodeName] = node;
  30. return oldNode || null;
  31. }
  32. removeNamedItem(name) {
  33. var oldNode;
  34. oldNode = this.nodes[name];
  35. delete this.nodes[name];
  36. return oldNode || null;
  37. }
  38. item(index) {
  39. return this.nodes[Object.keys(this.nodes)[index]] || null;
  40. }
  41. // DOM level 2 functions to be implemented later
  42. getNamedItemNS(namespaceURI, localName) {
  43. throw new Error("This DOM method is not implemented.");
  44. }
  45. setNamedItemNS(node) {
  46. throw new Error("This DOM method is not implemented.");
  47. }
  48. removeNamedItemNS(namespaceURI, localName) {
  49. throw new Error("This DOM method is not implemented.");
  50. }
  51. };
  52. // DOM level 1
  53. Object.defineProperty(XMLNamedNodeMap.prototype, 'length', {
  54. get: function() {
  55. return Object.keys(this.nodes).length || 0;
  56. }
  57. });
  58. return XMLNamedNodeMap;
  59. }).call(this);
  60. }).call(this);