@nodecfdi/cfdi-cleaner
Version:
Librería para limpiar comprobantes fiscales digitales v3.3 y v4.0
22 lines (21 loc) • 702 B
JavaScript
/**
* This provides methods used for xml attributes handling. It´s not meant to
* be used directly.
*/
export default class XmlAttributeMethods {
attributeRemove(attribute) {
const { ownerElement, nodeName } = attribute;
/* istanbul ignore else -- For usage always is not null but for default ownerElement is posible null @preserve */
if (ownerElement !== null) {
ownerElement.removeAttribute(nodeName);
}
}
attributeSetValueOrRemoveIfEmpty(attribute, value) {
if (value === '') {
this.attributeRemove(attribute);
return;
}
attribute.value = value;
attribute.nodeValue = value;
}
}