UNPKG

@taiga-ui/cdk

Version:

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

28 lines 1.24 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.removeAttr = removeAttr; /** * Finds an attribute on a parsed element by name (checks both `attrName` and `[attrName]` forms), * removes it via the recorder, and returns the value. * * @returns `value` is `null` when the attribute was not present. */ function removeAttr(element, attrName, recorder, templateOffset) { var _a, _b, _c; const nameLower = attrName.toLowerCase(); const bindingLower = `[${nameLower}]`; for (const attr of element.attrs) { const attrNameLower = attr.name.toLowerCase(); if (attrNameLower !== nameLower && attrNameLower !== bindingLower) { continue; } const { startOffset = 0, endOffset = 0 } = (_c = (_b = (_a = element.sourceCodeLocation) === null || _a === void 0 ? void 0 : _a.attrs) === null || _b === void 0 ? void 0 : _b[attr.name]) !== null && _c !== void 0 ? _c : {}; recorder.remove(templateOffset + startOffset, endOffset - startOffset); return { value: attr.value, isBinding: attrNameLower.startsWith('['), }; } return { value: null, isBinding: false }; } //# sourceMappingURL=remove-attr.js.map