XMLAttribute.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. // Generated by CoffeeScript 1.12.7
  2. (function() {
  3. var XMLAttribute;
  4. module.exports = XMLAttribute = (function() {
  5. function XMLAttribute(parent, name, value) {
  6. this.options = parent.options;
  7. this.stringify = parent.stringify;
  8. this.parent = parent;
  9. if (name == null) {
  10. throw new Error("Missing attribute name. " + this.debugInfo(name));
  11. }
  12. if (value == null) {
  13. throw new Error("Missing attribute value. " + this.debugInfo(name));
  14. }
  15. this.name = this.stringify.attName(name);
  16. this.value = this.stringify.attValue(value);
  17. }
  18. XMLAttribute.prototype.clone = function() {
  19. return Object.create(this);
  20. };
  21. XMLAttribute.prototype.toString = function(options) {
  22. return this.options.writer.set(options).attribute(this);
  23. };
  24. XMLAttribute.prototype.debugInfo = function(name) {
  25. name = name || this.name;
  26. if (name == null) {
  27. return "parent: <" + this.parent.name + ">";
  28. } else {
  29. return "attribute: {" + name + "}, parent: <" + this.parent.name + ">";
  30. }
  31. };
  32. return XMLAttribute;
  33. })();
  34. }).call(this);