@schukai/monster 5.2.1 → 5.2.2
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/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,17 @@
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
|
|
5
|
+
## [5.2.2] - 2026-11-08
|
|
6
|
+
|
|
7
|
+
### Bug Fixes
|
|
8
|
+
|
|
9
|
+
- **updater:** scope inserted node ownership to its container ([#607](https://gitlab.schukai.com/oss/libraries/javascript/monster/issues/607))
|
|
10
|
+
### Tests
|
|
11
|
+
|
|
12
|
+
- **tabs:** normalize mocked button geometry across browsers ([#607](https://gitlab.schukai.com/oss/libraries/javascript/monster/issues/607))
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
5
16
|
## [5.2.1] - 2026-10-12
|
|
6
17
|
|
|
7
18
|
### Bug Fixes
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"author":"Volker Schukai","dependencies":{"@floating-ui/dom":"^1.7.6"},"description":"Monster is a simple library for creating fast, robust and lightweight websites.","exports":{".":"./source/monster.mjs","./CHANGELOG.md":"./CHANGELOG.md","./LICENSE":"./LICENSE","./README.md":"./README.md","./documentation/migrations/monster-5-options.md":"./documentation/migrations/monster-5-options.md","./package.json":"./package.json","./source/*":"./source/*","./test/*":"./test/*"},"files":["source","test/cases","test/util","documentation/migrations/monster-5-options.md","CHANGELOG.md"],"homepage":"https://monsterjs.org/","keywords":["framework","web","dom","css","sass","mobile-first","app","front-end","templates","schukai","core","shopcloud","alvine","monster","buildmap","stack","observer","observable","uuid","node","nodelist","css-in-js","logger","log","theme"],"license":"AGPL 3.0","main":"source/monster.mjs","module":"source/monster.mjs","name":"@schukai/monster","repository":{"type":"git","url":"https://gitlab.schukai.com/oss/libraries/javascript/monster.git"},"sideEffects":["./source/monster.mjs","./source/components/**","./source/i18n/**","./test/**"],"type":"module","version":"5.2.
|
|
1
|
+
{"author":"Volker Schukai","dependencies":{"@floating-ui/dom":"^1.7.6"},"description":"Monster is a simple library for creating fast, robust and lightweight websites.","exports":{".":"./source/monster.mjs","./CHANGELOG.md":"./CHANGELOG.md","./LICENSE":"./LICENSE","./README.md":"./README.md","./documentation/migrations/monster-5-options.md":"./documentation/migrations/monster-5-options.md","./package.json":"./package.json","./source/*":"./source/*","./test/*":"./test/*"},"files":["source","test/cases","test/util","documentation/migrations/monster-5-options.md","CHANGELOG.md"],"homepage":"https://monsterjs.org/","keywords":["framework","web","dom","css","sass","mobile-first","app","front-end","templates","schukai","core","shopcloud","alvine","monster","buildmap","stack","observer","observable","uuid","node","nodelist","css-in-js","logger","log","theme"],"license":"AGPL 3.0","main":"source/monster.mjs","module":"source/monster.mjs","name":"@schukai/monster","repository":{"type":"git","url":"https://gitlab.schukai.com/oss/libraries/javascript/monster.git"},"sideEffects":["./source/monster.mjs","./source/components/**","./source/i18n/**","./test/**"],"type":"module","version":"5.2.2"}
|
package/source/dom/updater.mjs
CHANGED
|
@@ -968,6 +968,9 @@ function insertElement(change, renderContext) {
|
|
|
968
968
|
for (const node of containerElement.querySelectorAll(
|
|
969
969
|
`[${ATTRIBUTE_UPDATER_INSERT_REFERENCE}]`,
|
|
970
970
|
)) {
|
|
971
|
+
// Template roots are appended directly to their owning container.
|
|
972
|
+
// Nested insert containers may use the same key and references.
|
|
973
|
+
if (node.parentNode !== containerElement) continue;
|
|
971
974
|
const ref = node.getAttribute(ATTRIBUTE_UPDATER_INSERT_REFERENCE);
|
|
972
975
|
if (!existing.has(ref)) {
|
|
973
976
|
existing.set(ref, node);
|
package/source/types/version.mjs
CHANGED
|
@@ -180,7 +180,10 @@ let VerticalTabs;
|
|
|
180
180
|
let restoreBoundingClientRect = null;
|
|
181
181
|
let restoreResizeObserver = null;
|
|
182
182
|
|
|
183
|
-
function waitForCondition(
|
|
183
|
+
function waitForCondition(
|
|
184
|
+
check,
|
|
185
|
+
{ timeout = 4000, interval = 10, message = "condition timed out" } = {},
|
|
186
|
+
) {
|
|
184
187
|
const startedAt = Date.now();
|
|
185
188
|
|
|
186
189
|
return new Promise((resolve, reject) => {
|
|
@@ -196,7 +199,7 @@ function waitForCondition(check, { timeout = 4000, interval = 10 } = {}) {
|
|
|
196
199
|
}
|
|
197
200
|
|
|
198
201
|
if (Date.now() - startedAt > timeout) {
|
|
199
|
-
reject(new Error(
|
|
202
|
+
reject(new Error(message));
|
|
200
203
|
return;
|
|
201
204
|
}
|
|
202
205
|
|
|
@@ -232,7 +235,9 @@ function installOverflowTabGeometryMock({
|
|
|
232
235
|
const label = this.textContent?.trim() || "";
|
|
233
236
|
|
|
234
237
|
if (role === "nav") {
|
|
235
|
-
return createRect({
|
|
238
|
+
return createRect({
|
|
239
|
+
width: typeof navWidth === "function" ? navWidth() : navWidth,
|
|
240
|
+
});
|
|
236
241
|
}
|
|
237
242
|
|
|
238
243
|
if (role === "button") {
|
|
@@ -721,6 +726,99 @@ describe("Tabs", function () {
|
|
|
721
726
|
});
|
|
722
727
|
});
|
|
723
728
|
|
|
729
|
+
it("should keep every rendered tab clickable after repeated width changes issue #607", async function () {
|
|
730
|
+
this.timeout(15000);
|
|
731
|
+
let width = 1800;
|
|
732
|
+
const observers = [];
|
|
733
|
+
const originalWindowObserver = window.ResizeObserver;
|
|
734
|
+
const originalGlobalObserver = global.ResizeObserver;
|
|
735
|
+
class TrackingResizeObserver extends ResizeObserverMock {
|
|
736
|
+
constructor(callback) {
|
|
737
|
+
super(callback);
|
|
738
|
+
observers.push(this);
|
|
739
|
+
}
|
|
740
|
+
}
|
|
741
|
+
window.ResizeObserver = global.ResizeObserver = TrackingResizeObserver;
|
|
742
|
+
restoreResizeObserver = () => {
|
|
743
|
+
window.ResizeObserver = originalWindowObserver;
|
|
744
|
+
global.ResizeObserver = originalGlobalObserver;
|
|
745
|
+
};
|
|
746
|
+
restoreBoundingClientRect = installOverflowTabGeometryMock({
|
|
747
|
+
navWidth: () => width,
|
|
748
|
+
});
|
|
749
|
+
const tabs = document.createElement("monster-tabs");
|
|
750
|
+
for (let index = 0; index < 14; index++) {
|
|
751
|
+
const panel = document.createElement("div");
|
|
752
|
+
panel.id = `resize-panel-${index}`;
|
|
753
|
+
panel.setAttribute(
|
|
754
|
+
"data-monster-button-label",
|
|
755
|
+
index < 6 ? `Long tab panel ${index}` : `Tab ${index}`,
|
|
756
|
+
);
|
|
757
|
+
tabs.appendChild(panel);
|
|
758
|
+
}
|
|
759
|
+
document.getElementById("mocks").appendChild(tabs);
|
|
760
|
+
const selector =
|
|
761
|
+
'button[data-monster-role="button"][data-monster-tab-reference]';
|
|
762
|
+
const references = Array.from(tabs.children, (panel) => panel.id);
|
|
763
|
+
await waitForCondition(
|
|
764
|
+
() => tabs.shadowRoot?.querySelectorAll(selector).length === 14,
|
|
765
|
+
{ message: "initial buttons missing" },
|
|
766
|
+
);
|
|
767
|
+
const nav = tabs.shadowRoot.querySelector('[data-monster-role="nav"]');
|
|
768
|
+
// Keep calcBoxWidth's CSS additions consistent with the mocked rects
|
|
769
|
+
// in browsers and JSDOM, including buttons recreated after a resize.
|
|
770
|
+
const geometryStyle = document.createElement("style");
|
|
771
|
+
geometryStyle.textContent = `
|
|
772
|
+
[data-monster-role="button"], [data-monster-role="switch"] {
|
|
773
|
+
border-width: 0 !important;
|
|
774
|
+
padding: 0 !important;
|
|
775
|
+
margin: 0 !important;
|
|
776
|
+
}
|
|
777
|
+
`;
|
|
778
|
+
tabs.shadowRoot.appendChild(geometryStyle);
|
|
779
|
+
await waitForCondition(
|
|
780
|
+
() => observers.some((item) => item.elements.includes(nav)),
|
|
781
|
+
{ message: "navigation resize observer missing" },
|
|
782
|
+
);
|
|
783
|
+
const observer = observers.find((item) => item.elements.includes(nav));
|
|
784
|
+
expect(observer).to.not.equal(undefined);
|
|
785
|
+
for (const nextWidth of [1000, 1800, 1000, 1800, 1000, 1800]) {
|
|
786
|
+
width = nextWidth;
|
|
787
|
+
observer.triggerResize([]);
|
|
788
|
+
await waitForCondition(
|
|
789
|
+
() => nextWidth === 1800
|
|
790
|
+
? tabs.getOption("buttons.standard").length === 14 &&
|
|
791
|
+
tabs.getOption("buttons.popper").length === 0
|
|
792
|
+
: tabs.getOption("buttons.popper").length > 0,
|
|
793
|
+
{ message: `options did not settle at width ${nextWidth}` },
|
|
794
|
+
);
|
|
795
|
+
await waitForCondition(() => {
|
|
796
|
+
const standard = Array.from(nav.children).filter((node) =>
|
|
797
|
+
node.matches(selector),
|
|
798
|
+
);
|
|
799
|
+
return standard.length === tabs.getOption("buttons.standard").length;
|
|
800
|
+
}, { message: `rendered standard buttons missing at width ${nextWidth}` });
|
|
801
|
+
const buttons = Array.from(tabs.shadowRoot.querySelectorAll(selector));
|
|
802
|
+
expect(buttons).to.have.length(14);
|
|
803
|
+
expect(buttons.map((button) =>
|
|
804
|
+
button.getAttribute("data-monster-tab-reference"),
|
|
805
|
+
)).to.have.members(references);
|
|
806
|
+
if (nextWidth === 1800) {
|
|
807
|
+
for (const button of buttons) {
|
|
808
|
+
button.click();
|
|
809
|
+
const panel = document.getElementById(
|
|
810
|
+
button.getAttribute("data-monster-tab-reference"),
|
|
811
|
+
);
|
|
812
|
+
await waitForCondition(() => panel.classList.contains("active"), {
|
|
813
|
+
message: `click failed for ${panel.id}`,
|
|
814
|
+
});
|
|
815
|
+
}
|
|
816
|
+
}
|
|
817
|
+
// Space deliberate resizes beyond the layout oscillation detector's window.
|
|
818
|
+
await new Promise((resolve) => setTimeout(resolve, 400));
|
|
819
|
+
}
|
|
820
|
+
});
|
|
821
|
+
|
|
724
822
|
it("should preserve the overflow split and recalculate widths while rebuilding tab buttons", async function () {
|
|
725
823
|
this.timeout(15000);
|
|
726
824
|
|
|
@@ -860,6 +860,54 @@ describe("DOM", function () {
|
|
|
860
860
|
});
|
|
861
861
|
});
|
|
862
862
|
|
|
863
|
+
[false, true].forEach((batchUpdates) => {
|
|
864
|
+
it(`should isolate nested insert ownership with batchUpdates=${batchUpdates} issue #607`, async function () {
|
|
865
|
+
document.getElementById("mocks").innerHTML = `
|
|
866
|
+
<template id="shared-row">
|
|
867
|
+
<strong data-monster-replace="path:shared-row.label"></strong>
|
|
868
|
+
<em data-monster-replace="path:shared-row.label"></em>
|
|
869
|
+
</template>
|
|
870
|
+
<div id="outer-rows" data-monster-insert="shared-row path:rows.outer">
|
|
871
|
+
<div id="inner-rows" data-monster-insert="shared-row path:rows.inner"></div>
|
|
872
|
+
</div>
|
|
873
|
+
`;
|
|
874
|
+
const outer = document.getElementById("outer-rows");
|
|
875
|
+
const inner = document.getElementById("inner-rows");
|
|
876
|
+
const updater = new Updater(outer, {
|
|
877
|
+
rows: {
|
|
878
|
+
outer: [{ label: "Outer" }],
|
|
879
|
+
inner: [{ label: "Inner" }, { label: "Extra" }],
|
|
880
|
+
},
|
|
881
|
+
});
|
|
882
|
+
updater.setBatchUpdates(batchUpdates);
|
|
883
|
+
const owned = () => Array.from(outer.children).filter((node) => node !== inner);
|
|
884
|
+
try {
|
|
885
|
+
await updater.run();
|
|
886
|
+
const innerNodes = Array.from(inner.children);
|
|
887
|
+
expect(innerNodes).to.have.length(4);
|
|
888
|
+
expect(owned()).to.have.length(2);
|
|
889
|
+
const firstOuter = owned()[0];
|
|
890
|
+
updater.getSubject().rows.outer = [];
|
|
891
|
+
await waitUntil(() => owned().length === 0, "outer rows should be removed");
|
|
892
|
+
expect(Array.from(inner.children)).to.deep.equal(innerNodes);
|
|
893
|
+
expect(outer.hasAttribute("data-monster-error")).to.equal(false);
|
|
894
|
+
|
|
895
|
+
updater.getSubject().rows.outer = [{ label: "Returned" }, { label: "Second" }];
|
|
896
|
+
await waitUntil(() => owned().length === 4, "outer rows must not reuse inner nodes");
|
|
897
|
+
expect(owned()[0]).to.not.equal(firstOuter);
|
|
898
|
+
expect(owned().map((node) => node.textContent)).to.deep.equal([
|
|
899
|
+
"Returned", "Returned", "Second", "Second",
|
|
900
|
+
]);
|
|
901
|
+
expect(Array.from(inner.children)).to.deep.equal(innerNodes);
|
|
902
|
+
updater.getSubject().rows.inner = [];
|
|
903
|
+
await waitUntil(() => inner.children.length === 0, "inner rows should be removed");
|
|
904
|
+
expect(owned().length).to.equal(4);
|
|
905
|
+
} finally {
|
|
906
|
+
updater.dispose();
|
|
907
|
+
}
|
|
908
|
+
});
|
|
909
|
+
});
|
|
910
|
+
|
|
863
911
|
it("should process two insert containers with the same data path issue #548", async function () {
|
|
864
912
|
const mocks = document.getElementById("mocks");
|
|
865
913
|
mocks.innerHTML = `
|