UNPKG

@progress/kendo-e2e

Version:

Kendo UI end-to-end test utilities.

30 lines 1.19 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.filterAttributes = filterAttributes; const isAngular = name => Boolean(name.match(/^(ng|_ng)/)); const isData = name => Boolean(name.match(/^data-/)); const isEmpty = (name, value) => value === '' && !name.match(/(checked|selected|readonly)/); const isGUID = (_, value) => Boolean(value.match(/^[A-Z0-9]{8}-[A-Z0-9]{4}-[A-Z0-9]{4}-[A-Z0-9]{4}-[A-Z0-9]{12}$/i)); const filters = [ isAngular, isData, isEmpty, isGUID ]; function filterAttributes(doc, root) { const nodeIterator = doc.createNodeIterator(root, 1 /* NodeFilter.SHOW_ELEMENT */); while (nodeIterator.nextNode()) { const node = nodeIterator.referenceNode; const attributes = node.attributes; const remove = []; for (let i = 0; i < attributes.length; i++) { const attr = attributes.item(i); const drop = filters.some(filter => filter(attr.name, attr.value)); if (drop) { remove.push(attr.name); } } remove.forEach(name => attributes.removeNamedItem(name)); } } //# sourceMappingURL=filter-attributes.js.map