@skirbi/sugar 0.1.14 → 0.1.15
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/Changes +4 -0
- package/lib/fakedom.mjs +1 -0
- package/lib/htmlelement-input.mjs +0 -2
- package/lib/htmlelement.mjs +11 -5
- package/lib/index.mjs +1 -1
- package/package.json +1 -1
package/Changes
CHANGED
package/lib/fakedom.mjs
CHANGED
|
@@ -41,6 +41,7 @@ export async function setupDomForTesting(
|
|
|
41
41
|
global.window = dom.window;
|
|
42
42
|
global.MutationObserver = dom.window.MutationObserver;
|
|
43
43
|
global.CustomEvent = dom.window.CustomEvent;
|
|
44
|
+
global.MouseEvent = dom.window.MouseEvent;
|
|
44
45
|
|
|
45
46
|
const projectRoot = process.cwd();
|
|
46
47
|
|
|
@@ -94,8 +94,6 @@ export class HTMLElementSugarInput extends HTMLElementSugar {
|
|
|
94
94
|
|
|
95
95
|
attributeChangedCallback(name, oldValue, newValue) {
|
|
96
96
|
super.attributeChangedCallback?.(name, oldValue, newValue);
|
|
97
|
-
|
|
98
|
-
|
|
99
97
|
if (name === 'value') {
|
|
100
98
|
this._value = newValue ?? '';
|
|
101
99
|
this._syncValueToControl();
|
package/lib/htmlelement.mjs
CHANGED
|
@@ -348,29 +348,35 @@ export class HTMLElementSugar extends HTMLElement {
|
|
|
348
348
|
/**
|
|
349
349
|
* Called when an observed attribute changes.
|
|
350
350
|
* @param {string} name - The attribute name
|
|
351
|
-
* @param {string|null} oldVal - Previous value (unused)
|
|
351
|
+
* @param {string|null} oldVal - Previous value (unused without a hook)
|
|
352
352
|
* @param {string|null} newVal - New value
|
|
353
353
|
*/
|
|
354
354
|
attributeChangedCallback(name, oldVal, newVal) {
|
|
355
355
|
this._applyAttribute(name, newVal);
|
|
356
356
|
|
|
357
|
-
if (!this.hasRenderedShape
|
|
357
|
+
if (!this.hasRenderedShape()) return;
|
|
358
358
|
|
|
359
359
|
const def = this.constructor.attributeDefs?.[name];
|
|
360
360
|
|
|
361
361
|
if (def?.hook) {
|
|
362
362
|
if (typeof def.hook === 'function') {
|
|
363
363
|
def.hook(this, newVal, oldVal);
|
|
364
|
-
}
|
|
364
|
+
}
|
|
365
|
+
else if (typeof def.hook === 'string') {
|
|
365
366
|
const el = this.querySelector(def.hook);
|
|
366
367
|
if (el) el.textContent = newVal ?? '';
|
|
367
368
|
}
|
|
368
|
-
}
|
|
369
|
+
}
|
|
370
|
+
else {
|
|
369
371
|
const el = this.querySelector(`[semtic-${name}]`);
|
|
370
372
|
if (el) el.textContent = newVal ?? '';
|
|
371
373
|
}
|
|
372
374
|
|
|
373
|
-
if (this.
|
|
375
|
+
if (this.updatedAttributeSugar) {
|
|
376
|
+
this.updatedAttributeSugar(name, oldVal, newVal);
|
|
377
|
+
}
|
|
378
|
+
else if (this.attributeChangedCallbackSugar) {
|
|
379
|
+
console.warn("Using deprecated attributeChangedCallbackSugar");
|
|
374
380
|
this.attributeChangedCallbackSugar(name, oldVal, newVal);
|
|
375
381
|
}
|
|
376
382
|
}
|
package/lib/index.mjs
CHANGED
package/package.json
CHANGED