UNPKG

@wildpeaks/snapshot-dom

Version:
1 lines 444 B
"use strict";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;