Use specific setter cache for builtin custom elements

pull/16592/head
Edoardo Cavazza 2 weeks ago
parent c6f6205398
commit 2117a15ef5

@ -238,7 +238,7 @@ export function set_custom_element_data(node, prop, value) {
// Don't compute setters for custom elements while they aren't registered yet, // Don't compute setters for custom elements while they aren't registered yet,
// because during their upgrade/instantiation they might add more setters. // because during their upgrade/instantiation they might add more setters.
// Instead, fall back to a simple "an object, then set as property" heuristic. // Instead, fall back to a simple "an object, then set as property" heuristic.
(setters_cache.has(node.nodeName) || (setters_cache.has(node.getAttribute('is') || node.nodeName) ||
// customElements may not be available in browser extension contexts // customElements may not be available in browser extension contexts
!customElements || !customElements ||
customElements.get(node.getAttribute('is') || node.tagName.toLowerCase()) customElements.get(node.getAttribute('is') || node.tagName.toLowerCase())
@ -546,9 +546,10 @@ var setters_cache = new Map();
/** @param {Element} element */ /** @param {Element} element */
function get_setters(element) { function get_setters(element) {
var setters = setters_cache.get(element.nodeName); var cache_key = element.getAttribute('is') || element.nodeName;
var setters = setters_cache.get(cache_key);
if (setters) return setters; if (setters) return setters;
setters_cache.set(element.nodeName, (setters = [])); setters_cache.set(cache_key, (setters = []));
var descriptors; var descriptors;
var proto = element; // In the case of custom elements there might be setters on the instance var proto = element; // In the case of custom elements there might be setters on the instance

Loading…
Cancel
Save