mutation-summary
Version:
Makes observing the DOM fast and easy
39 lines • 1.36 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.Qualifier = void 0;
var Qualifier = /** @class */ (function () {
function Qualifier() {
}
Qualifier.prototype.matches = function (oldValue) {
if (oldValue === null)
return false;
if (this.attrValue === undefined)
return true;
if (!this.contains)
return this.attrValue == oldValue;
var tokens = oldValue.split(' ');
for (var i = 0; i < tokens.length; i++) {
if (this.attrValue === tokens[i])
return true;
}
return false;
};
Qualifier.prototype.toString = function () {
if (this.attrName === 'class' && this.contains)
return '.' + this.attrValue;
if (this.attrName === 'id' && !this.contains)
return '#' + this.attrValue;
if (this.contains)
return '[' + this.attrName + '~=' + escapeQuotes(this.attrValue) + ']';
if ('attrValue' in this)
return '[' + this.attrName + '=' + escapeQuotes(this.attrValue) + ']';
//@ts-ignore
return '[' + this.attrName + ']';
};
return Qualifier;
}());
exports.Qualifier = Qualifier;
function escapeQuotes(value) {
return '"' + value.replace(/"/, '\\\"') + '"';
}
//# sourceMappingURL=Qualifier.js.map
;