thunderous 1.1.0 → 2.0.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.
package/dist/index.cjs CHANGED
@@ -18,8 +18,8 @@ var __copyProps = (to, from, except, desc) => {
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
19
 
20
20
  // src/index.ts
21
- var src_exports = {};
22
- __export(src_exports, {
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
23
  clientOnlyCallback: () => clientOnlyCallback,
24
24
  createEffect: () => createEffect,
25
25
  createRegistry: () => createRegistry,
@@ -31,443 +31,7 @@ __export(src_exports, {
31
31
  insertTemplates: () => insertTemplates,
32
32
  onServerDefine: () => onServerDefine
33
33
  });
34
- module.exports = __toCommonJS(src_exports);
35
-
36
- // vendor/@webcomponents/scoped-custom-element-registry/src/scoped-custom-element-registry.js
37
- if (typeof window !== "undefined") {
38
- if (!ShadowRoot.prototype.createElement) {
39
- const NativeHTMLElement = window.HTMLElement;
40
- const nativeDefine = window.customElements.define;
41
- const nativeGet = window.customElements.get;
42
- const nativeRegistry = window.customElements;
43
- const definitionForElement = /* @__PURE__ */ new WeakMap();
44
- const pendingRegistryForElement = /* @__PURE__ */ new WeakMap();
45
- const globalDefinitionForConstructor = /* @__PURE__ */ new WeakMap();
46
- const scopeForElement = /* @__PURE__ */ new WeakMap();
47
- window.CustomElementRegistry = class {
48
- constructor() {
49
- this._definitionsByTag = /* @__PURE__ */ new Map();
50
- this._definitionsByClass = /* @__PURE__ */ new Map();
51
- this._whenDefinedPromises = /* @__PURE__ */ new Map();
52
- this._awaitingUpgrade = /* @__PURE__ */ new Map();
53
- }
54
- define(tagName, elementClass) {
55
- tagName = tagName.toLowerCase();
56
- if (this._getDefinition(tagName) !== void 0) {
57
- throw new DOMException(
58
- `Failed to execute 'define' on 'CustomElementRegistry': the name "${tagName}" has already been used with this registry`
59
- );
60
- }
61
- if (this._definitionsByClass.get(elementClass) !== void 0) {
62
- throw new DOMException(
63
- `Failed to execute 'define' on 'CustomElementRegistry': this constructor has already been used with this registry`
64
- );
65
- }
66
- const attributeChangedCallback = elementClass.prototype.attributeChangedCallback;
67
- const observedAttributes = new Set(elementClass.observedAttributes || []);
68
- patchAttributes(
69
- elementClass,
70
- observedAttributes,
71
- attributeChangedCallback
72
- );
73
- const definition = {
74
- elementClass,
75
- connectedCallback: elementClass.prototype.connectedCallback,
76
- disconnectedCallback: elementClass.prototype.disconnectedCallback,
77
- adoptedCallback: elementClass.prototype.adoptedCallback,
78
- attributeChangedCallback,
79
- "formAssociated": elementClass["formAssociated"],
80
- "formAssociatedCallback": elementClass.prototype["formAssociatedCallback"],
81
- "formDisabledCallback": elementClass.prototype["formDisabledCallback"],
82
- "formResetCallback": elementClass.prototype["formResetCallback"],
83
- "formStateRestoreCallback": elementClass.prototype["formStateRestoreCallback"],
84
- observedAttributes
85
- };
86
- this._definitionsByTag.set(tagName, definition);
87
- this._definitionsByClass.set(elementClass, definition);
88
- let standInClass = nativeGet.call(nativeRegistry, tagName);
89
- if (!standInClass) {
90
- standInClass = createStandInElement(tagName);
91
- nativeDefine.call(nativeRegistry, tagName, standInClass);
92
- }
93
- if (this === window.customElements) {
94
- globalDefinitionForConstructor.set(elementClass, definition);
95
- definition.standInClass = standInClass;
96
- }
97
- const awaiting = this._awaitingUpgrade.get(tagName);
98
- if (awaiting) {
99
- this._awaitingUpgrade.delete(tagName);
100
- for (const element of awaiting) {
101
- pendingRegistryForElement.delete(element);
102
- customize(element, definition, true);
103
- }
104
- }
105
- const info = this._whenDefinedPromises.get(tagName);
106
- if (info !== void 0) {
107
- info.resolve(elementClass);
108
- this._whenDefinedPromises.delete(tagName);
109
- }
110
- return elementClass;
111
- }
112
- upgrade() {
113
- creationContext.push(this);
114
- nativeRegistry.upgrade.apply(nativeRegistry, arguments);
115
- creationContext.pop();
116
- }
117
- get(tagName) {
118
- const definition = this._definitionsByTag.get(tagName);
119
- return definition?.elementClass;
120
- }
121
- _getDefinition(tagName) {
122
- return this._definitionsByTag.get(tagName);
123
- }
124
- whenDefined(tagName) {
125
- const definition = this._getDefinition(tagName);
126
- if (definition !== void 0) {
127
- return Promise.resolve(definition.elementClass);
128
- }
129
- let info = this._whenDefinedPromises.get(tagName);
130
- if (info === void 0) {
131
- info = {};
132
- info.promise = new Promise((r) => info.resolve = r);
133
- this._whenDefinedPromises.set(tagName, info);
134
- }
135
- return info.promise;
136
- }
137
- _upgradeWhenDefined(element, tagName, shouldUpgrade) {
138
- let awaiting = this._awaitingUpgrade.get(tagName);
139
- if (!awaiting) {
140
- this._awaitingUpgrade.set(tagName, awaiting = /* @__PURE__ */ new Set());
141
- }
142
- if (shouldUpgrade) {
143
- awaiting.add(element);
144
- } else {
145
- awaiting.delete(element);
146
- }
147
- }
148
- };
149
- let upgradingInstance;
150
- window.HTMLElement = function HTMLElement2() {
151
- let instance = upgradingInstance;
152
- if (instance) {
153
- upgradingInstance = void 0;
154
- return instance;
155
- }
156
- const definition = globalDefinitionForConstructor.get(this.constructor);
157
- if (!definition) {
158
- throw new TypeError(
159
- "Illegal constructor (custom element class must be registered with global customElements registry to be newable)"
160
- );
161
- }
162
- instance = Reflect.construct(
163
- NativeHTMLElement,
164
- [],
165
- definition.standInClass
166
- );
167
- Object.setPrototypeOf(instance, this.constructor.prototype);
168
- definitionForElement.set(instance, definition);
169
- return instance;
170
- };
171
- window.HTMLElement.prototype = NativeHTMLElement.prototype;
172
- const isValidScope = (node) => node === document || node instanceof ShadowRoot;
173
- const registryForNode = (node) => {
174
- let scope = node.getRootNode();
175
- if (!isValidScope(scope)) {
176
- const context = creationContext[creationContext.length - 1];
177
- if (context instanceof CustomElementRegistry) {
178
- return context;
179
- }
180
- scope = context.getRootNode();
181
- if (!isValidScope(scope)) {
182
- scope = scopeForElement.get(scope)?.getRootNode() || document;
183
- }
184
- }
185
- return scope.customElements;
186
- };
187
- const createStandInElement = (tagName) => {
188
- return class ScopedCustomElementBase {
189
- static get ["formAssociated"]() {
190
- return true;
191
- }
192
- constructor() {
193
- const instance = Reflect.construct(
194
- NativeHTMLElement,
195
- [],
196
- this.constructor
197
- );
198
- Object.setPrototypeOf(instance, HTMLElement.prototype);
199
- const registry = registryForNode(instance) || window.customElements;
200
- const definition = registry._getDefinition(tagName);
201
- if (definition) {
202
- customize(instance, definition);
203
- } else {
204
- pendingRegistryForElement.set(instance, registry);
205
- }
206
- return instance;
207
- }
208
- connectedCallback() {
209
- const definition = definitionForElement.get(this);
210
- if (definition) {
211
- definition.connectedCallback && definition.connectedCallback.apply(this, arguments);
212
- } else {
213
- pendingRegistryForElement.get(this)._upgradeWhenDefined(this, tagName, true);
214
- }
215
- }
216
- disconnectedCallback() {
217
- const definition = definitionForElement.get(this);
218
- if (definition) {
219
- definition.disconnectedCallback && definition.disconnectedCallback.apply(this, arguments);
220
- } else {
221
- pendingRegistryForElement.get(this)._upgradeWhenDefined(this, tagName, false);
222
- }
223
- }
224
- adoptedCallback() {
225
- const definition = definitionForElement.get(this);
226
- definition?.adoptedCallback?.apply(this, arguments);
227
- }
228
- // Form-associated custom elements lifecycle methods
229
- ["formAssociatedCallback"]() {
230
- const definition = definitionForElement.get(this);
231
- if (definition && definition["formAssociated"]) {
232
- definition?.["formAssociatedCallback"]?.apply(this, arguments);
233
- }
234
- }
235
- ["formDisabledCallback"]() {
236
- const definition = definitionForElement.get(this);
237
- if (definition?.["formAssociated"]) {
238
- definition?.["formDisabledCallback"]?.apply(this, arguments);
239
- }
240
- }
241
- ["formResetCallback"]() {
242
- const definition = definitionForElement.get(this);
243
- if (definition?.["formAssociated"]) {
244
- definition?.["formResetCallback"]?.apply(this, arguments);
245
- }
246
- }
247
- ["formStateRestoreCallback"]() {
248
- const definition = definitionForElement.get(this);
249
- if (definition?.["formAssociated"]) {
250
- definition?.["formStateRestoreCallback"]?.apply(this, arguments);
251
- }
252
- }
253
- // no attributeChangedCallback or observedAttributes since these
254
- // are simulated via setAttribute/removeAttribute patches
255
- };
256
- };
257
- const patchAttributes = (elementClass, observedAttributes, attributeChangedCallback) => {
258
- if (observedAttributes.size === 0 || attributeChangedCallback === void 0) {
259
- return;
260
- }
261
- const setAttribute = elementClass.prototype.setAttribute;
262
- if (setAttribute) {
263
- elementClass.prototype.setAttribute = function(n, value) {
264
- const name = n.toLowerCase();
265
- if (observedAttributes.has(name)) {
266
- const old = this.getAttribute(name);
267
- setAttribute.call(this, name, value);
268
- attributeChangedCallback.call(this, name, old, value);
269
- } else {
270
- setAttribute.call(this, name, value);
271
- }
272
- };
273
- }
274
- const removeAttribute = elementClass.prototype.removeAttribute;
275
- if (removeAttribute) {
276
- elementClass.prototype.removeAttribute = function(n) {
277
- const name = n.toLowerCase();
278
- if (observedAttributes.has(name)) {
279
- const old = this.getAttribute(name);
280
- removeAttribute.call(this, name);
281
- attributeChangedCallback.call(this, name, old, null);
282
- } else {
283
- removeAttribute.call(this, name);
284
- }
285
- };
286
- }
287
- const toggleAttribute = elementClass.prototype.toggleAttribute;
288
- if (toggleAttribute) {
289
- elementClass.prototype.toggleAttribute = function(n, force) {
290
- const name = n.toLowerCase();
291
- if (observedAttributes.has(name)) {
292
- const old = this.getAttribute(name);
293
- toggleAttribute.call(this, name, force);
294
- const newValue = this.getAttribute(name);
295
- attributeChangedCallback.call(this, name, old, newValue);
296
- } else {
297
- toggleAttribute.call(this, name, force);
298
- }
299
- };
300
- }
301
- };
302
- const patchHTMLElement = (elementClass) => {
303
- const parentClass = Object.getPrototypeOf(elementClass);
304
- if (parentClass !== window.HTMLElement) {
305
- if (parentClass === NativeHTMLElement) {
306
- return Object.setPrototypeOf(elementClass, window.HTMLElement);
307
- }
308
- return patchHTMLElement(parentClass);
309
- }
310
- };
311
- const customize = (instance, definition, isUpgrade = false) => {
312
- Object.setPrototypeOf(instance, definition.elementClass.prototype);
313
- definitionForElement.set(instance, definition);
314
- upgradingInstance = instance;
315
- try {
316
- new definition.elementClass();
317
- } catch (_) {
318
- patchHTMLElement(definition.elementClass);
319
- new definition.elementClass();
320
- }
321
- if (definition.attributeChangedCallback) {
322
- definition.observedAttributes.forEach((attr) => {
323
- if (instance.hasAttribute(attr)) {
324
- definition.attributeChangedCallback.call(
325
- instance,
326
- attr,
327
- null,
328
- instance.getAttribute(attr)
329
- );
330
- }
331
- });
332
- }
333
- if (isUpgrade && definition.connectedCallback && instance.isConnected) {
334
- definition.connectedCallback.call(instance);
335
- }
336
- };
337
- const nativeAttachShadow = Element.prototype.attachShadow;
338
- Element.prototype.attachShadow = function(init) {
339
- const shadowRoot = nativeAttachShadow.apply(this, arguments);
340
- if (init.customElements) {
341
- shadowRoot.customElements = init.customElements;
342
- }
343
- return shadowRoot;
344
- };
345
- let creationContext = [document];
346
- const installScopedCreationMethod = (ctor, method, from = void 0) => {
347
- const native = (from ? Object.getPrototypeOf(from) : ctor.prototype)[method];
348
- ctor.prototype[method] = function() {
349
- creationContext.push(this);
350
- const ret = native.apply(from || this, arguments);
351
- if (ret !== void 0) {
352
- scopeForElement.set(ret, this);
353
- }
354
- creationContext.pop();
355
- return ret;
356
- };
357
- };
358
- installScopedCreationMethod(ShadowRoot, "createElement", document);
359
- installScopedCreationMethod(ShadowRoot, "importNode", document);
360
- installScopedCreationMethod(Element, "insertAdjacentHTML");
361
- installScopedCreationMethod(Node, "appendChild");
362
- installScopedCreationMethod(Element, "append");
363
- const installScopedCreationSetter = (ctor, name) => {
364
- const descriptor = Object.getOwnPropertyDescriptor(ctor.prototype, name);
365
- Object.defineProperty(ctor.prototype, name, {
366
- ...descriptor,
367
- set(value) {
368
- creationContext.push(this);
369
- descriptor.set.call(this, value);
370
- creationContext.pop();
371
- }
372
- });
373
- };
374
- installScopedCreationSetter(Element, "innerHTML");
375
- installScopedCreationSetter(ShadowRoot, "innerHTML");
376
- Object.defineProperty(window, "customElements", {
377
- value: new CustomElementRegistry(),
378
- configurable: true,
379
- writable: true
380
- });
381
- if (!!window["ElementInternals"] && !!window["ElementInternals"].prototype["setFormValue"]) {
382
- const internalsToHostMap = /* @__PURE__ */ new WeakMap();
383
- const attachInternals = HTMLElement.prototype["attachInternals"];
384
- const methods = [
385
- "setFormValue",
386
- "setValidity",
387
- "checkValidity",
388
- "reportValidity"
389
- ];
390
- HTMLElement.prototype["attachInternals"] = function(...args) {
391
- const internals = attachInternals.call(this, ...args);
392
- internalsToHostMap.set(internals, this);
393
- return internals;
394
- };
395
- methods.forEach((method) => {
396
- const proto = window["ElementInternals"].prototype;
397
- const originalMethod = proto[method];
398
- proto[method] = function(...args) {
399
- const host = internalsToHostMap.get(this);
400
- const definition = definitionForElement.get(host);
401
- if (definition["formAssociated"] === true) {
402
- return originalMethod?.call(this, ...args);
403
- } else {
404
- throw new DOMException(
405
- `Failed to execute ${originalMethod} on 'ElementInternals': The target element is not a form-associated custom element.`
406
- );
407
- }
408
- };
409
- });
410
- class RadioNodeList extends Array {
411
- constructor(elements) {
412
- super(...elements);
413
- this._elements = elements;
414
- }
415
- get ["value"]() {
416
- return this._elements.find((element) => element["checked"] === true)?.value || "";
417
- }
418
- }
419
- class HTMLFormControlsCollection {
420
- constructor(elements) {
421
- const entries = /* @__PURE__ */ new Map();
422
- elements.forEach((element, index) => {
423
- const name = element.getAttribute("name");
424
- const nameReference = entries.get(name) || [];
425
- this[+index] = element;
426
- nameReference.push(element);
427
- entries.set(name, nameReference);
428
- });
429
- this["length"] = elements.length;
430
- entries.forEach((value, key) => {
431
- if (!value) return;
432
- if (value.length === 1) {
433
- this[key] = value[0];
434
- } else {
435
- this[key] = new RadioNodeList(value);
436
- }
437
- });
438
- }
439
- ["namedItem"](key) {
440
- return this[key];
441
- }
442
- }
443
- const formElementsDescriptor = Object.getOwnPropertyDescriptor(
444
- HTMLFormElement.prototype,
445
- "elements"
446
- );
447
- Object.defineProperty(HTMLFormElement.prototype, "elements", {
448
- get: function() {
449
- const nativeElements = formElementsDescriptor.get.call(this, []);
450
- const include = [];
451
- for (const element of nativeElements) {
452
- const definition = definitionForElement.get(element);
453
- if (!definition || definition["formAssociated"] === true) {
454
- include.push(element);
455
- }
456
- }
457
- return new HTMLFormControlsCollection(include);
458
- }
459
- });
460
- }
461
- }
462
- class TrackableCustomElementRegistry extends window.CustomElementRegistry {
463
- __tagNames = /* @__PURE__ */ new Set();
464
- define(tagName, constructor, options) {
465
- super.define(tagName, constructor, options);
466
- this.__tagNames.add(tagName);
467
- }
468
- }
469
- window.CustomElementRegistry = TrackableCustomElementRegistry;
470
- }
34
+ module.exports = __toCommonJS(index_exports);
471
35
 
472
36
  // src/constants.ts
473
37
  var DEFAULT_RENDER_OPTIONS = {
@@ -511,6 +75,7 @@ var createSignal = (initVal, options) => {
511
75
  }
512
76
  return value;
513
77
  };
78
+ getter.getter = true;
514
79
  const setter = (newValue, setterOptions) => {
515
80
  const isObject = typeof newValue === "object" && newValue !== null;
516
81
  if (!isObject && value === newValue) return;
@@ -647,7 +212,12 @@ var getServerRenderArgs = (tagName, registry) => ({
647
212
  formStateRestoreCallback: NOOP,
648
213
  formAssociatedCallback: NOOP,
649
214
  clientOnlyCallback: NOOP,
650
- customCallback: () => `{{callback:unavailable-on-server}}`,
215
+ customCallback: () => "",
216
+ getter: (fn) => {
217
+ const _fn = () => fn();
218
+ _fn.getter = true;
219
+ return _fn;
220
+ },
651
221
  attrSignals: new Proxy({}, { get: (_, attr) => createSignal(`{{attr:${String(attr)}}}`) }),
652
222
  propSignals: new Proxy({}, { get: () => createSignal(null) }),
653
223
  refs: {},
@@ -701,20 +271,19 @@ var clientOnlyCallback = (fn) => {
701
271
  };
702
272
 
703
273
  // src/render.ts
274
+ var renderState = {
275
+ currentShadowRoot: null
276
+ };
704
277
  var clearHTML = (element) => {
705
278
  while (element.childNodes.length > 0) {
706
279
  element.childNodes[0].remove();
707
280
  }
708
281
  };
709
282
  var parseFragment = (htmlStr) => {
710
- const range = document.createRange();
711
- range.selectNode(document.body);
712
- return range.createContextualFragment(htmlStr);
713
- };
714
- var setInnerHTML = (element, html2) => {
715
- clearHTML(element);
716
- const fragment = typeof html2 === "string" ? parseFragment(html2) : html2;
717
- element.append(fragment);
283
+ const template = document.createElement("template");
284
+ template.innerHTML = htmlStr;
285
+ const fragment = renderState.currentShadowRoot === null ? template.content : renderState.currentShadowRoot.importNode(template.content, true);
286
+ return fragment;
718
287
  };
719
288
  var logValueError = (value) => {
720
289
  console.error(
@@ -768,13 +337,14 @@ var getNewNode = (value, parent) => {
768
337
  var html = (strings, ...values) => {
769
338
  let innerHTML = "";
770
339
  const signalMap = /* @__PURE__ */ new Map();
340
+ const callbackMap = /* @__PURE__ */ new Map();
771
341
  const processValue = (value) => {
772
342
  if (!isServer && value instanceof DocumentFragment) {
773
343
  const tempDiv = document.createElement("div");
774
344
  tempDiv.append(value.cloneNode(true));
775
345
  return tempDiv.innerHTML;
776
346
  }
777
- if (typeof value === "function") {
347
+ if (typeof value === "function" && "getter" in value && value.getter === true) {
778
348
  const getter = value;
779
349
  const uniqueKey = crypto.randomUUID();
780
350
  signalMap.set(uniqueKey, getter);
@@ -784,6 +354,11 @@ var html = (strings, ...values) => {
784
354
  }
785
355
  return isServer ? String(result) : `{{signal:${uniqueKey}}}`;
786
356
  }
357
+ if (typeof value === "function") {
358
+ const uniqueKey = crypto.randomUUID();
359
+ callbackMap.set(uniqueKey, value);
360
+ return isServer ? String(value()) : `{{callback:${uniqueKey}}}`;
361
+ }
787
362
  if (typeof value === "object" && value !== null) {
788
363
  logValueError(value);
789
364
  return "";
@@ -804,6 +379,7 @@ var html = (strings, ...values) => {
804
379
  }
805
380
  const fragment = parseFragment(innerHTML);
806
381
  const callbackBindingRegex = /(\{\{callback:.+\}\})/;
382
+ const legacyCallbackBindingRegex = /(this.getRootNode\(\).host.__customCallbackFns.get\('.+'\)\(event\))/;
807
383
  const signalBindingRegex = /(\{\{signal:.+\}\})/;
808
384
  const parseChildren = (element) => {
809
385
  for (const child of element.childNodes) {
@@ -866,14 +442,29 @@ var html = (strings, ...values) => {
866
442
  child.setAttribute(attr.name, newText);
867
443
  }
868
444
  });
869
- } else if (callbackBindingRegex.test(attr.value)) {
445
+ } else if (legacyCallbackBindingRegex.test(attr.value)) {
870
446
  const getRootNode = child.getRootNode.bind(child);
871
447
  child.getRootNode = () => {
872
448
  const rootNode = getRootNode();
873
449
  return rootNode instanceof ShadowRoot ? rootNode : fragment;
874
450
  };
875
- const uniqueKey = attr.value.replace(/\{\{callback:(.+)\}\}/, "$1");
876
- child.setAttribute(attr.name, `this.getRootNode().host.__customCallbackFns.get('${uniqueKey}')(event)`);
451
+ } else if (callbackBindingRegex.test(attr.value)) {
452
+ const textList = attr.value.split(callbackBindingRegex);
453
+ createEffect(() => {
454
+ child.__customCallbackFns = child.__customCallbackFns ?? /* @__PURE__ */ new Map();
455
+ let uniqueKey = "";
456
+ for (const text of textList) {
457
+ const _uniqueKey = text.replace(/\{\{callback:(.+)\}\}/, "$1");
458
+ if (_uniqueKey !== text) uniqueKey = _uniqueKey;
459
+ const callback = uniqueKey !== text ? callbackMap.get(uniqueKey) : void 0;
460
+ if (callback !== void 0) {
461
+ child.__customCallbackFns.set(uniqueKey, callback);
462
+ }
463
+ }
464
+ if (uniqueKey !== "") {
465
+ child.setAttribute(attr.name, `this.__customCallbackFns.get('${uniqueKey}')(event)`);
466
+ }
467
+ });
877
468
  }
878
469
  }
879
470
  parseChildren(child);
@@ -1024,6 +615,7 @@ var customElement = (render, options) => {
1024
615
  });
1025
616
  #render() {
1026
617
  const root = this.#shadowRoot ?? this;
618
+ renderState.currentShadowRoot = this.#shadowRoot;
1027
619
  const fragment = render({
1028
620
  elementRef: this,
1029
621
  root,
@@ -1037,10 +629,15 @@ var customElement = (render, options) => {
1037
629
  formResetCallback: (fn) => this.#formResetCallbackFns.add(fn),
1038
630
  formStateRestoreCallback: (fn) => this.#formStateRestoreCallbackFns.add(fn),
1039
631
  clientOnlyCallback: (fn) => this.#clientOnlyCallbackFns.add(fn),
632
+ getter: (fn) => {
633
+ const _fn = () => fn();
634
+ _fn.getter = true;
635
+ return _fn;
636
+ },
1040
637
  customCallback: (fn) => {
1041
638
  const key = crypto.randomUUID();
1042
639
  this.__customCallbackFns.set(key, fn);
1043
- return `{{callback:${key}}}`;
640
+ return `this.getRootNode().host.__customCallbackFns.get('${key}')(event)`;
1044
641
  },
1045
642
  attrSignals: new Proxy(
1046
643
  {},
@@ -1078,6 +675,7 @@ You must set an initial value before calling a property signal's getter.
1078
675
  );
1079
676
  return value;
1080
677
  };
678
+ getter.getter = true;
1081
679
  return [getter, setter];
1082
680
  },
1083
681
  set: () => {
@@ -1120,25 +718,11 @@ You must set an initial value before calling a property signal's getter.
1120
718
  }
1121
719
  });
1122
720
  fragment.host = this;
1123
- const registry = shadowRootOptions.registry instanceof CustomElementRegistry ? shadowRootOptions.registry : shadowRootOptions.registry?.eject();
1124
- const tempContainer = document.createElement("div");
1125
- tempContainer.append(fragment.cloneNode(true));
1126
- const fragmentContent = tempContainer.innerHTML;
1127
- root.innerHTML = fragmentContent;
1128
- if (registry?.__tagNames !== void 0) {
1129
- for (const tagName of registry.__tagNames) {
1130
- const upgradedElements = root.querySelectorAll(tagName);
1131
- const nonUpgradedElements = fragment.querySelectorAll(tagName);
1132
- upgradedElements.forEach((upgradedElement, index) => {
1133
- const nonUpgradedElement = nonUpgradedElements[index];
1134
- nonUpgradedElement.replaceWith(upgradedElement);
1135
- });
1136
- }
1137
- }
1138
721
  for (const fn of this.#clientOnlyCallbackFns) {
1139
722
  fn();
1140
723
  }
1141
- setInnerHTML(root, fragment);
724
+ clearHTML(root);
725
+ root.append(fragment);
1142
726
  }
1143
727
  static get formAssociated() {
1144
728
  return formAssociated;
@@ -1338,16 +922,3 @@ var createRegistry = (args) => {
1338
922
  insertTemplates,
1339
923
  onServerDefine
1340
924
  });
1341
- /**
1342
- * @license
1343
- * Copyright (c) 2020 The Polymer Project Authors. All rights reserved.
1344
- * This code may only be used under the BSD style license found at
1345
- * http://polymer.github.io/LICENSE.txt
1346
- * The complete set of authors may be found at
1347
- * http://polymer.github.io/AUTHORS.txt
1348
- * The complete set of contributors may be found at
1349
- * http://polymer.github.io/CONTRIBUTORS.txt
1350
- * Code distributed by Google as part of the polymer project is also
1351
- * subject to an additional IP rights grant found at
1352
- * http://polymer.github.io/PATENTS.txt
1353
- */