123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- var error_1 = require("../error");
- var validate_1 = require("../validate");
- var XmlComment = (function () {
- function XmlComment(parent, validation, options) {
- this._validation = validation;
- if (!(0, validate_1.isUndefined)(options.replaceInvalidCharsInCharData)) {
- this._replaceInvalidCharsInCharData = (options.replaceInvalidCharsInCharData);
- }
- else {
- this._replaceInvalidCharsInCharData = false;
- }
- this._parent = parent;
- this.charData = options.charData;
- }
- Object.defineProperty(XmlComment.prototype, "charData", {
-
- get: function () {
- return this._charData;
- },
-
- set: function (charData) {
- if (this._replaceInvalidCharsInCharData) {
- charData = (0, validate_1.fixChar)(charData);
- }
- else if (this._validation && !(0, validate_1.validateChar)(charData)) {
- throw new Error((0, error_1.getContext)(this.up()) + ": comment content"
- + (" \"" + charData + "\" should not contain characters")
- + " not allowed in XML");
- }
- if (this._replaceInvalidCharsInCharData) {
- charData = charData.replace("--", "\uFFFD\uFFFD");
- }
- else if (this._validation && charData.indexOf("--") !== -1) {
- throw new Error((0, error_1.getContext)(this.up()) + ": comment content"
- + (" \"" + charData + "\" should not contain the string")
- + " '--'");
- }
- if (this._replaceInvalidCharsInCharData) {
- if (charData.lastIndexOf("-") === charData.length - 1) {
- charData = charData.substr(0, charData.length - 1) + "\uFFFD";
- }
- }
- else if (this._validation
- && charData.lastIndexOf("-") === charData.length - 1) {
- throw new Error((0, error_1.getContext)(this.up()) + ": comment content"
- + (" \"" + charData + "\" should not end with the string")
- + " '-'");
- }
- this._charData = charData;
- },
- enumerable: false,
- configurable: true
- });
-
- XmlComment.prototype.toString = function () {
- return "<!--" + this._charData + "-->";
- };
-
- XmlComment.prototype.up = function () {
- return this._parent;
- };
- return XmlComment;
- }());
- exports.default = XmlComment;
|