@lmjs/core 2.4.1 → 2.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2984,14 +2984,34 @@ function avc(t, n, o, d = null) {
2984
2984
  // real jQuery only becomes active once a project selects ANY real
2985
2985
  // plugin, this was a real, latent regression risk for the plain
2986
2986
  // @scroll case too, the moment such a project selected one).
2987
+ // 2026-10-03: no more full-document scan. It read every element's attributes (7 patched getAttribute calls per
2988
+ // element) on every globalWatch()/reloads() — about half of all script time on a big console.roxyon.com page.
2989
+ // Engine-created elements are indexed by @-name when createEl() wires their events (_lmIndexAtEl); raw HTML that
2990
+ // carries real @ attributes is found with one native selector query.
2991
+ var _lmAtIndex = new Map();
2992
+ function _lmIndexAtEl(el, name) {
2993
+ var set = _lmAtIndex.get(name);
2994
+ if (!set) { set = new Set(); _lmAtIndex.set(name, set); }
2995
+ set.add(el);
2996
+ // Detached elements are kept (a persistent widget's DOM can be re-attached); prune only if the set grows large.
2997
+ if (set.size > 5000) set.forEach(function (e) { if (!e.isConnected) set.delete(e); });
2998
+ }
2987
2999
  function _findByAtAttrNames(names) {
2988
- var all = document.querySelectorAll("*");
2989
3000
  var out = [];
2990
- for (var i = 0; i < all.length; i++) {
2991
- for (var j = 0; j < names.length; j++) {
2992
- if (all[i].getAttribute(names[j]) != null) { out.push(all[i]); break; }
2993
- }
3001
+ var seen = new Set();
3002
+ for (var j = 0; j < names.length; j++) {
3003
+ var set = _lmAtIndex.get(names[j]);
3004
+ if (!set) continue;
3005
+ set.forEach(function (el) {
3006
+ if (seen.has(el) || !el.isConnected) return;
3007
+ if (el.events && el.events[names[j]] != null) { seen.add(el); out.push(el); }
3008
+ });
2994
3009
  }
3010
+ try {
3011
+ var sel = names.map(function (n) { return "[\\" + n + "]"; }).join(",");
3012
+ var raw = document.querySelectorAll(sel);
3013
+ for (var i = 0; i < raw.length; i++) if (!seen.has(raw[i])) { seen.add(raw[i]); out.push(raw[i]); }
3014
+ } catch (e) { }
2995
3015
  return out;
2996
3016
  }
2997
3017