XMLText.js 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. // Generated by CoffeeScript 1.12.7
  2. (function() {
  3. var NodeType, XMLCharacterData, XMLText,
  4. extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
  5. hasProp = {}.hasOwnProperty;
  6. NodeType = require('./NodeType');
  7. XMLCharacterData = require('./XMLCharacterData');
  8. module.exports = XMLText = (function(superClass) {
  9. extend(XMLText, superClass);
  10. function XMLText(parent, text) {
  11. XMLText.__super__.constructor.call(this, parent);
  12. if (text == null) {
  13. throw new Error("Missing element text. " + this.debugInfo());
  14. }
  15. this.name = "#text";
  16. this.type = NodeType.Text;
  17. this.value = this.stringify.text(text);
  18. }
  19. Object.defineProperty(XMLText.prototype, 'isElementContentWhitespace', {
  20. get: function() {
  21. throw new Error("This DOM method is not implemented." + this.debugInfo());
  22. }
  23. });
  24. Object.defineProperty(XMLText.prototype, 'wholeText', {
  25. get: function() {
  26. var next, prev, str;
  27. str = '';
  28. prev = this.previousSibling;
  29. while (prev) {
  30. str = prev.data + str;
  31. prev = prev.previousSibling;
  32. }
  33. str += this.data;
  34. next = this.nextSibling;
  35. while (next) {
  36. str = str + next.data;
  37. next = next.nextSibling;
  38. }
  39. return str;
  40. }
  41. });
  42. XMLText.prototype.clone = function() {
  43. return Object.create(this);
  44. };
  45. XMLText.prototype.toString = function(options) {
  46. return this.options.writer.text(this, this.options.writer.filterOptions(options));
  47. };
  48. XMLText.prototype.splitText = function(offset) {
  49. throw new Error("This DOM method is not implemented." + this.debugInfo());
  50. };
  51. XMLText.prototype.replaceWholeText = function(content) {
  52. throw new Error("This DOM method is not implemented." + this.debugInfo());
  53. };
  54. return XMLText;
  55. })(XMLCharacterData);
  56. }).call(this);