(html)
| 247 | * @param {string} html |
| 248 | */ |
| 249 | export function sortAttributes(html) { |
| 250 | return html.replace( |
| 251 | /<([a-z0-9-]+)((?:\s[a-z0-9:_.-]+=".*?")+)((?:\s*\/)?>)/gi, |
| 252 | (s, pre, attrs, after) => { |
| 253 | let list = attrs |
| 254 | .match(/\s[a-z0-9:_.-]+=".*?"/gi) |
| 255 | .sort((a, b) => (a > b ? 1 : -1)); |
| 256 | if (~after.indexOf('/')) after = '></' + pre + '>'; |
| 257 | return '<' + pre + list.join('') + after; |
| 258 | } |
| 259 | ); |
| 260 | } |
| 261 | |
| 262 | let attributesSpy, originalAttributesPropDescriptor; |
| 263 |
no test coverage detected
searching dependent graphs…