UNPKG

@taiga-ui/cdk

Version:

Base library for creating Angular components and applications using Taiga UI principles regarding of actual visual appearance

19 lines 1.36 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.replaceTag = void 0; const START_TAG_OFFSET = 1; const END_TAG_OFFSET = 2; // eslint-disable-next-line @typescript-eslint/max-params,max-params function replaceTag(recorder, sourceCodeLocation, from, to, templateOffset = 0, addAttributes = []) { var _a, _b, _c; const startTagOffset = (_b = (_a = sourceCodeLocation === null || sourceCodeLocation === void 0 ? void 0 : sourceCodeLocation.startTag) === null || _a === void 0 ? void 0 : _a.startOffset) !== null && _b !== void 0 ? _b : 0; const endTagOffset = (_c = sourceCodeLocation === null || sourceCodeLocation === void 0 ? void 0 : sourceCodeLocation.endTag) === null || _c === void 0 ? void 0 : _c.startOffset; if (endTagOffset) { recorder.remove(endTagOffset + templateOffset + END_TAG_OFFSET, from.length); recorder.insertRight(endTagOffset + templateOffset + END_TAG_OFFSET, to); } recorder.remove((startTagOffset !== null && startTagOffset !== void 0 ? startTagOffset : 0) + templateOffset + START_TAG_OFFSET, from.length); recorder.insertRight((startTagOffset !== null && startTagOffset !== void 0 ? startTagOffset : 0) + templateOffset + START_TAG_OFFSET, `${to} ${addAttributes.join(' ')}`); } exports.replaceTag = replaceTag; //# sourceMappingURL=replace-tag.js.map