perf: improve get_setters cache (#13343)

gh-13256
Conduitry 2 months ago committed by GitHub
parent de157ee1dc
commit 1a5cf6fef4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -184,8 +184,7 @@ export function set_attributes(
next.class = next.class ? next.class + ' ' + css_hash : css_hash; next.class = next.class ? next.class + ' ' + css_hash : css_hash;
} }
var setters = setters_cache.get(element.nodeName); var setters = get_setters(element);
if (!setters) setters_cache.set(element.nodeName, (setters = get_setters(element)));
// @ts-expect-error // @ts-expect-error
var attributes = /** @type {Record<string, unknown>} **/ (element.__attributes ??= {}); var attributes = /** @type {Record<string, unknown>} **/ (element.__attributes ??= {});
@ -356,8 +355,9 @@ var setters_cache = new Map();
/** @param {Element} element */ /** @param {Element} element */
function get_setters(element) { function get_setters(element) {
/** @type {string[]} */ var setters = setters_cache.get(element.nodeName);
var setters = []; if (setters) return setters;
setters_cache.set(element.nodeName, (setters = []));
var descriptors; var descriptors;
var proto = get_prototype_of(element); var proto = get_prototype_of(element);

Loading…
Cancel
Save