@wildpeaks/snapshot-dom
Version:
Converts a DOM element to a JSON tree
1 lines • 444 B
JavaScript
;function sortAttributeValue(t){return"string"==typeof t?t.trim().replace(/[\s]+/g," ").split(" ").sort().join(" "):t}function sortAttributes(t,r){if("object"==typeof t&&null!==t&&Array.isArray(r)&&(Array.isArray(t.childNodes)&&t.childNodes.forEach(t=>sortAttributes(t,r)),t&&t.attributes))for(const s in t.attributes)r.includes(s)&&(t.attributes[s]=sortAttributeValue(t.attributes[s]))}module.exports.sortAttributes=sortAttributes;