MCPcopy
hub / github.com/preactjs/preact / sortAttributes

Function sortAttributes

test/_util/helpers.jsx:249–260  ·  view source on GitHub ↗
(html)

Source from the content-addressed store, hash-verified

247 * @param {string} html
248 */
249export 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
262let attributesSpy, originalAttributesPropDescriptor;
263

Callers 7

render.test.jsxFile · 0.90
svg.test.jsxFile · 0.90
hydrate.test.jsxFile · 0.90
render.test.jsxFile · 0.90
svg.test.jsxFile · 0.90

Calls 1

sortMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…