XMLAttribute.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. // Generated by CoffeeScript 1.12.7
  2. (function() {
  3. var NodeType, XMLAttribute, XMLNode;
  4. NodeType = require('./NodeType');
  5. XMLNode = require('./XMLNode');
  6. module.exports = XMLAttribute = (function() {
  7. function XMLAttribute(parent, name, value) {
  8. this.parent = parent;
  9. if (this.parent) {
  10. this.options = this.parent.options;
  11. this.stringify = this.parent.stringify;
  12. }
  13. if (name == null) {
  14. throw new Error("Missing attribute name. " + this.debugInfo(name));
  15. }
  16. this.name = this.stringify.name(name);
  17. this.value = this.stringify.attValue(value);
  18. this.type = NodeType.Attribute;
  19. this.isId = false;
  20. this.schemaTypeInfo = null;
  21. }
  22. Object.defineProperty(XMLAttribute.prototype, 'nodeType', {
  23. get: function() {
  24. return this.type;
  25. }
  26. });
  27. Object.defineProperty(XMLAttribute.prototype, 'ownerElement', {
  28. get: function() {
  29. return this.parent;
  30. }
  31. });
  32. Object.defineProperty(XMLAttribute.prototype, 'textContent', {
  33. get: function() {
  34. return this.value;
  35. },
  36. set: function(value) {
  37. return this.value = value || '';
  38. }
  39. });
  40. Object.defineProperty(XMLAttribute.prototype, 'namespaceURI', {
  41. get: function() {
  42. return '';
  43. }
  44. });
  45. Object.defineProperty(XMLAttribute.prototype, 'prefix', {
  46. get: function() {
  47. return '';
  48. }
  49. });
  50. Object.defineProperty(XMLAttribute.prototype, 'localName', {
  51. get: function() {
  52. return this.name;
  53. }
  54. });
  55. Object.defineProperty(XMLAttribute.prototype, 'specified', {
  56. get: function() {
  57. return true;
  58. }
  59. });
  60. XMLAttribute.prototype.clone = function() {
  61. return Object.create(this);
  62. };
  63. XMLAttribute.prototype.toString = function(options) {
  64. return this.options.writer.attribute(this, this.options.writer.filterOptions(options));
  65. };
  66. XMLAttribute.prototype.debugInfo = function(name) {
  67. name = name || this.name;
  68. if (name == null) {
  69. return "parent: <" + this.parent.name + ">";
  70. } else {
  71. return "attribute: {" + name + "}, parent: <" + this.parent.name + ">";
  72. }
  73. };
  74. XMLAttribute.prototype.isEqualNode = function(node) {
  75. if (node.namespaceURI !== this.namespaceURI) {
  76. return false;
  77. }
  78. if (node.prefix !== this.prefix) {
  79. return false;
  80. }
  81. if (node.localName !== this.localName) {
  82. return false;
  83. }
  84. if (node.value !== this.value) {
  85. return false;
  86. }
  87. return true;
  88. };
  89. return XMLAttribute;
  90. })();
  91. }).call(this);