UNPKG

@rxap/xml-parser

Version:

Provides a set of decorators and services for parsing and serializing XML documents into TypeScript classes. It simplifies the process of mapping XML elements and attributes to class properties, handling data validation, and serializing objects back into

39 lines 1.68 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ChildElementMixin = void 0; const tslib_1 = require("tslib"); const mixin_1 = require("@rxap/mixin"); const utilities_1 = require("@rxap/utilities"); const path_element_mixin_1 = require("./path-element.mixin"); const required_element_mixin_1 = require("./required-element.mixin"); let ChildElementMixin = class ChildElementMixin { constructor(elementTypeOrFunction, options = {}) { this.elementTypeOrFunction = elementTypeOrFunction; this.options = options; } get elementType() { let elementType = this.elementTypeOrFunction; if (elementType && typeof elementType === 'function' && !(0, utilities_1.isConstructor)(elementType)) { elementType = elementType(); } return elementType; } get tag() { var _a, _b; const tag = (_a = this.options.tag) !== null && _a !== void 0 ? _a : (_b = this.elementType) === null || _b === void 0 ? void 0 : _b.TAG; if (!tag) { throw new Error('[ElementChildParser] The element tag is not defined'); } return tag; } get hasTag() { var _a; return this.options.tag || ((_a = this.elementType) === null || _a === void 0 ? void 0 : _a.TAG); } }; exports.ChildElementMixin = ChildElementMixin; exports.ChildElementMixin = ChildElementMixin = tslib_1.__decorate([ (0, mixin_1.Mixin)(required_element_mixin_1.RequiredElementMixin, path_element_mixin_1.PathElementMixin), tslib_1.__metadata("design:paramtypes", [Object, Object]) ], ChildElementMixin); //# sourceMappingURL=child-element.mixin.js.map