@spectrum-web-components/shared 0.14.4 → 0.14.5
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/package.json +52 -6
- package/src/first-focusable-in.dev.js +6 -0
- package/src/first-focusable-in.dev.js.map +7 -0
- package/src/first-focusable-in.js +3 -14
- package/src/first-focusable-in.js.map +7 -1
- package/src/focus-visible.dev.js +68 -0
- package/src/focus-visible.dev.js.map +7 -0
- package/src/focus-visible.js +59 -105
- package/src/focus-visible.js.map +7 -1
- package/src/focusable.dev.js +190 -0
- package/src/focusable.dev.js.map +7 -0
- package/src/focusable.js +185 -244
- package/src/focusable.js.map +7 -1
- package/src/get-active-element.dev.js +4 -0
- package/src/get-active-element.dev.js.map +7 -0
- package/src/get-active-element.js +2 -14
- package/src/get-active-element.js.map +7 -1
- package/src/get-deep-element-from-point.dev.js +12 -0
- package/src/get-deep-element-from-point.dev.js.map +7 -0
- package/src/get-deep-element-from-point.js +9 -20
- package/src/get-deep-element-from-point.js.map +7 -1
- package/src/index.dev.js +10 -0
- package/src/index.dev.js.map +7 -0
- package/src/index.js +10 -21
- package/src/index.js.map +7 -1
- package/src/like-anchor.dev.js +58 -0
- package/src/like-anchor.dev.js.map +7 -0
- package/src/like-anchor.js +45 -40
- package/src/like-anchor.js.map +7 -1
- package/src/observe-slot-presence.dev.js +52 -0
- package/src/observe-slot-presence.dev.js.map +7 -0
- package/src/observe-slot-presence.js +47 -55
- package/src/observe-slot-presence.js.map +7 -1
- package/src/observe-slot-text.dev.js +79 -0
- package/src/observe-slot-text.dev.js.map +7 -0
- package/src/observe-slot-text.js +73 -64
- package/src/observe-slot-text.js.map +7 -1
- package/src/platform.dev.js +31 -0
- package/src/platform.dev.js.map +7 -0
- package/src/platform.js +11 -32
- package/src/platform.js.map +7 -1
- package/src/reparent-children.dev.js +50 -0
- package/src/reparent-children.dev.js.map +7 -0
- package/src/reparent-children.js +44 -52
- package/src/reparent-children.js.map +7 -1
- package/test/focusable.test.js +19 -31
- package/test/focusable.test.js.map +7 -1
- package/test/observe-slot-presence.test.js +17 -27
- package/test/observe-slot-presence.test.js.map +7 -1
- package/test/observe-slot-text.test.js +17 -28
- package/test/observe-slot-text.test.js.map +7 -1
- package/test/reparent-children.test.js +151 -162
- package/test/reparent-children.test.js.map +7 -1
|
@@ -1,34 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
-
of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
-
Unless required by applicable law or agreed to in writing, software distributed under
|
|
7
|
-
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
8
|
-
OF ANY KIND, either express or implied. See the License for the specific language
|
|
9
|
-
governing permissions and limitations under the License.
|
|
10
|
-
*/
|
|
11
|
-
import { ObserveSlotPresence } from '../src/observe-slot-presence.js';
|
|
12
|
-
import { LitElement } from '@spectrum-web-components/base';
|
|
13
|
-
import { elementUpdated, expect, fixture, html } from '@open-wc/testing';
|
|
1
|
+
import { ObserveSlotPresence } from "@spectrum-web-components/shared/src/observe-slot-presence.js";
|
|
2
|
+
import { LitElement } from "@spectrum-web-components/base";
|
|
3
|
+
import { elementUpdated, expect, fixture, html } from "@open-wc/testing";
|
|
14
4
|
class ObserverTest extends ObserveSlotPresence(LitElement, '[slot="test-slot"]') {
|
|
15
|
-
|
|
16
|
-
|
|
5
|
+
render() {
|
|
6
|
+
return html`
|
|
17
7
|
Test Element
|
|
18
8
|
`;
|
|
19
|
-
|
|
9
|
+
}
|
|
20
10
|
}
|
|
21
|
-
customElements.define(
|
|
22
|
-
describe(
|
|
23
|
-
|
|
24
|
-
|
|
11
|
+
customElements.define("observe-presence-test", ObserverTest);
|
|
12
|
+
describe("ObserveSlotPresence", () => {
|
|
13
|
+
it("does no management when slot unavailable", async () => {
|
|
14
|
+
const el = await fixture(html`
|
|
25
15
|
<observe-presence-test></observe-presence-test>
|
|
26
16
|
`);
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
17
|
+
await elementUpdated(el);
|
|
18
|
+
expect(el.slotContentIsPresent).to.be.false;
|
|
19
|
+
el.innerHTML = '<div slot="test-slot"></div>';
|
|
20
|
+
await elementUpdated(el);
|
|
21
|
+
expect(el.slotContentIsPresent).to.be.true;
|
|
22
|
+
});
|
|
33
23
|
});
|
|
34
|
-
//# sourceMappingURL=observe-slot-presence.test.js.map
|
|
24
|
+
//# sourceMappingURL=observe-slot-presence.test.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["observe-slot-presence.test.ts"],
|
|
4
|
+
"sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport { ObserveSlotPresence } from '@spectrum-web-components/shared/src/observe-slot-presence.js';\nimport { LitElement, TemplateResult } from '@spectrum-web-components/base';\nimport { elementUpdated, expect, fixture, html } from '@open-wc/testing';\n\nclass ObserverTest extends ObserveSlotPresence(\n LitElement,\n '[slot=\"test-slot\"]'\n) {\n protected override render(): TemplateResult {\n return html`\n Test Element\n `;\n }\n}\n\ncustomElements.define('observe-presence-test', ObserverTest);\n\ndescribe('ObserveSlotPresence', () => {\n it('does no management when slot unavailable', async () => {\n const el = await fixture<ObserverTest>(\n html`\n <observe-presence-test></observe-presence-test>\n `\n );\n await elementUpdated(el);\n\n expect(el.slotContentIsPresent).to.be.false;\n\n el.innerHTML = '<div slot=\"test-slot\"></div>';\n await elementUpdated(el);\n\n expect(el.slotContentIsPresent).to.be.true;\n });\n});\n"],
|
|
5
|
+
"mappings": "AAWA;AACA;AACA;AAEA,MAAM,qBAAqB,oBACvB,YACA,oBACJ,EAAE;AAAA,EACqB,SAAyB;AACxC,WAAO;AAAA;AAAA;AAAA,EAGX;AACJ;AAEA,eAAe,OAAO,yBAAyB,YAAY;AAE3D,SAAS,uBAAuB,MAAM;AAClC,KAAG,4CAA4C,YAAY;AACvD,UAAM,KAAK,MAAM,QACb;AAAA;AAAA,aAGJ;AACA,UAAM,eAAe,EAAE;AAEvB,WAAO,GAAG,oBAAoB,EAAE,GAAG,GAAG;AAEtC,OAAG,YAAY;AACf,UAAM,eAAe,EAAE;AAEvB,WAAO,GAAG,oBAAoB,EAAE,GAAG,GAAG;AAAA,EAC1C,CAAC;AACL,CAAC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,35 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
-
of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
-
|
|
7
|
-
Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
-
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
-
OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
-
governing permissions and limitations under the License.
|
|
11
|
-
*/
|
|
12
|
-
import { ObserveSlotText } from '../src/observe-slot-text.js';
|
|
13
|
-
import { LitElement } from '@spectrum-web-components/base';
|
|
14
|
-
import { elementUpdated, expect, fixture, html } from '@open-wc/testing';
|
|
1
|
+
import { ObserveSlotText } from "@spectrum-web-components/shared/src/observe-slot-text.js";
|
|
2
|
+
import { LitElement } from "@spectrum-web-components/base";
|
|
3
|
+
import { elementUpdated, expect, fixture, html } from "@open-wc/testing";
|
|
15
4
|
class ObserverTest extends ObserveSlotText(LitElement) {
|
|
16
|
-
|
|
17
|
-
|
|
5
|
+
render() {
|
|
6
|
+
return html`
|
|
18
7
|
<slot @slotchange=${this.manageTextObservedSlot}></slot>
|
|
19
8
|
`;
|
|
20
|
-
|
|
9
|
+
}
|
|
21
10
|
}
|
|
22
|
-
customElements.define(
|
|
23
|
-
describe(
|
|
24
|
-
|
|
25
|
-
|
|
11
|
+
customElements.define("observe-slot-test", ObserverTest);
|
|
12
|
+
describe("ObserveSlotText", () => {
|
|
13
|
+
it("does no management when slot unavailable", async () => {
|
|
14
|
+
const el = await fixture(html`
|
|
26
15
|
<observe-slot-test></observe-slot-test>
|
|
27
16
|
`);
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
17
|
+
await elementUpdated(el);
|
|
18
|
+
expect(el.slotHasContent).to.be.false;
|
|
19
|
+
el.textContent = `hi, i'm some text`;
|
|
20
|
+
await elementUpdated(el);
|
|
21
|
+
expect(el.slotHasContent).to.be.true;
|
|
22
|
+
});
|
|
34
23
|
});
|
|
35
|
-
//# sourceMappingURL=observe-slot-text.test.js.map
|
|
24
|
+
//# sourceMappingURL=observe-slot-text.test.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["observe-slot-text.test.ts"],
|
|
4
|
+
"sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport { ObserveSlotText } from '@spectrum-web-components/shared/src/observe-slot-text.js';\nimport { LitElement, TemplateResult } from '@spectrum-web-components/base';\nimport { elementUpdated, expect, fixture, html } from '@open-wc/testing';\n\nclass ObserverTest extends ObserveSlotText(LitElement) {\n protected override render(): TemplateResult {\n return html`\n <slot @slotchange=${this.manageTextObservedSlot}></slot>\n `;\n }\n}\n\ncustomElements.define('observe-slot-test', ObserverTest);\n\ndescribe('ObserveSlotText', () => {\n it('does no management when slot unavailable', async () => {\n const el = await fixture<ObserverTest>(\n html`\n <observe-slot-test></observe-slot-test>\n `\n );\n await elementUpdated(el);\n\n expect(el.slotHasContent).to.be.false;\n\n el.textContent = `hi, i'm some text`;\n\n await elementUpdated(el);\n\n expect(el.slotHasContent).to.be.true;\n });\n});\n"],
|
|
5
|
+
"mappings": "AAYA;AACA;AACA;AAEA,MAAM,qBAAqB,gBAAgB,UAAU,EAAE;AAAA,EAChC,SAAyB;AACxC,WAAO;AAAA,gCACiB,KAAK;AAAA;AAAA,EAEjC;AACJ;AAEA,eAAe,OAAO,qBAAqB,YAAY;AAEvD,SAAS,mBAAmB,MAAM;AAC9B,KAAG,4CAA4C,YAAY;AACvD,UAAM,KAAK,MAAM,QACb;AAAA;AAAA,aAGJ;AACA,UAAM,eAAe,EAAE;AAEvB,WAAO,GAAG,cAAc,EAAE,GAAG,GAAG;AAEhC,OAAG,cAAc;AAEjB,UAAM,eAAe,EAAE;AAEvB,WAAO,GAAG,cAAc,EAAE,GAAG,GAAG;AAAA,EACpC,CAAC;AACL,CAAC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,19 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
-
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
-
OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
-
governing permissions and limitations under the License.
|
|
11
|
-
*/
|
|
12
|
-
import { expect, fixture, html } from '@open-wc/testing';
|
|
13
|
-
import { reparentChildren } from '../src/reparent-children.js';
|
|
14
|
-
describe('Reparent Children', () => {
|
|
15
|
-
it('reparents and returns a single child', async () => {
|
|
16
|
-
const context = await fixture(html `
|
|
1
|
+
import { expect, fixture, html } from "@open-wc/testing";
|
|
2
|
+
import { reparentChildren } from "@spectrum-web-components/shared/src/reparent-children.js";
|
|
3
|
+
describe("Reparent Children", () => {
|
|
4
|
+
it("reparents and returns a single child", async () => {
|
|
5
|
+
const context = await fixture(html`
|
|
17
6
|
<div>
|
|
18
7
|
<div class="source">
|
|
19
8
|
<div class="child"></div>
|
|
@@ -21,39 +10,39 @@ describe('Reparent Children', () => {
|
|
|
21
10
|
<div class="destination"></div>
|
|
22
11
|
</div>
|
|
23
12
|
`);
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
13
|
+
const source = context.querySelector(".source");
|
|
14
|
+
const child = context.querySelector(".child");
|
|
15
|
+
const destination = context.querySelector(".destination");
|
|
16
|
+
expect(source.children.length).to.equal(1);
|
|
17
|
+
expect(destination.children.length).to.equal(0);
|
|
18
|
+
const restore = reparentChildren([child], destination);
|
|
19
|
+
expect(source.children.length).to.equal(0);
|
|
20
|
+
expect(destination.children.length).to.equal(1);
|
|
21
|
+
restore();
|
|
22
|
+
expect(source.children.length).to.equal(1);
|
|
23
|
+
expect(destination.children.length).to.equal(0);
|
|
24
|
+
});
|
|
25
|
+
it("early exits no children", async () => {
|
|
26
|
+
const context = await fixture(html`
|
|
38
27
|
<div>
|
|
39
28
|
<div class="source"></div>
|
|
40
29
|
<div class="destination"></div>
|
|
41
30
|
</div>
|
|
42
31
|
`);
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
32
|
+
const source = context.querySelector(".source");
|
|
33
|
+
const children = [...source.children];
|
|
34
|
+
const destination = context.querySelector(".destination");
|
|
35
|
+
expect(source.children.length).to.equal(0);
|
|
36
|
+
expect(destination.children.length).to.equal(0);
|
|
37
|
+
const restore = reparentChildren(children, destination);
|
|
38
|
+
expect(source.children.length).to.equal(0);
|
|
39
|
+
expect(destination.children.length).to.equal(0);
|
|
40
|
+
restore();
|
|
41
|
+
expect(source.children.length).to.equal(0);
|
|
42
|
+
expect(destination.children.length).to.equal(0);
|
|
43
|
+
});
|
|
44
|
+
it("reparents and returns multiple child", async () => {
|
|
45
|
+
const context = await fixture(html`
|
|
57
46
|
<div>
|
|
58
47
|
<div class="source">
|
|
59
48
|
<div class="child"></div>
|
|
@@ -65,20 +54,20 @@ describe('Reparent Children', () => {
|
|
|
65
54
|
<div class="destination"></div>
|
|
66
55
|
</div>
|
|
67
56
|
`);
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
57
|
+
const source = context.querySelector(".source");
|
|
58
|
+
const { children } = source;
|
|
59
|
+
const destination = context.querySelector(".destination");
|
|
60
|
+
expect(source.children.length).to.equal(5);
|
|
61
|
+
expect(destination.children.length).to.equal(0);
|
|
62
|
+
const restore = reparentChildren([...children], destination);
|
|
63
|
+
expect(source.children.length).to.equal(0);
|
|
64
|
+
expect(destination.children.length).to.equal(5);
|
|
65
|
+
restore();
|
|
66
|
+
expect(source.children.length).to.equal(5);
|
|
67
|
+
expect(destination.children.length).to.equal(0);
|
|
68
|
+
});
|
|
69
|
+
it("augments the child via a callback", async () => {
|
|
70
|
+
const context = await fixture(html`
|
|
82
71
|
<div>
|
|
83
72
|
<div class="source">
|
|
84
73
|
<div class="child" slot="slot"></div>
|
|
@@ -86,26 +75,26 @@ describe('Reparent Children', () => {
|
|
|
86
75
|
<div class="destination"></div>
|
|
87
76
|
</div>
|
|
88
77
|
`);
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
});
|
|
102
|
-
expect(child.hasAttribute('slot')).to.be.false;
|
|
103
|
-
restore();
|
|
104
|
-
expect(child.getAttribute('slot')).to.equal('slot');
|
|
78
|
+
const child = context.querySelector(".child");
|
|
79
|
+
const destination = context.querySelector(".destination");
|
|
80
|
+
expect(child.getAttribute("slot")).to.equal("slot");
|
|
81
|
+
const restore = reparentChildren([child], destination, {
|
|
82
|
+
position: "beforeend",
|
|
83
|
+
prepareCallback: (el) => {
|
|
84
|
+
const slotName = el.slot;
|
|
85
|
+
el.removeAttribute("slot");
|
|
86
|
+
return (el2) => {
|
|
87
|
+
el2.slot = slotName;
|
|
88
|
+
};
|
|
89
|
+
}
|
|
105
90
|
});
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
91
|
+
expect(child.hasAttribute("slot")).to.be.false;
|
|
92
|
+
restore();
|
|
93
|
+
expect(child.getAttribute("slot")).to.equal("slot");
|
|
94
|
+
});
|
|
95
|
+
it("beforeend - reparents and returns multiple children", async () => {
|
|
96
|
+
var _a, _b, _c, _d;
|
|
97
|
+
const context = await fixture(html`
|
|
109
98
|
<div>
|
|
110
99
|
<div class="source">
|
|
111
100
|
<div class="child">1</div>
|
|
@@ -119,29 +108,29 @@ describe('Reparent Children', () => {
|
|
|
119
108
|
</div>
|
|
120
109
|
</div>
|
|
121
110
|
`);
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
});
|
|
130
|
-
expect(source.children.length).to.equal(0);
|
|
131
|
-
expect(destination.children.length).to.equal(5 + 1);
|
|
132
|
-
const marker = context.querySelector('.marker');
|
|
133
|
-
expect(marker.previousElementSibling).to.be.null;
|
|
134
|
-
expect((_a = marker.nextElementSibling) === null || _a === void 0 ? void 0 : _a.textContent).to.equal('1');
|
|
135
|
-
expect((_b = destination.lastElementChild) === null || _b === void 0 ? void 0 : _b.textContent).to.equal('5');
|
|
136
|
-
restore();
|
|
137
|
-
expect(source.children.length).to.equal(5);
|
|
138
|
-
expect(destination.children.length).to.equal(1);
|
|
139
|
-
expect((_c = source.firstElementChild) === null || _c === void 0 ? void 0 : _c.textContent).to.equal('1');
|
|
140
|
-
expect((_d = source.lastElementChild) === null || _d === void 0 ? void 0 : _d.textContent).to.equal('5');
|
|
111
|
+
const source = context.querySelector(".source");
|
|
112
|
+
const { children } = source;
|
|
113
|
+
const destination = context.querySelector(".destination");
|
|
114
|
+
expect(source.children.length).to.equal(5);
|
|
115
|
+
expect(destination.children.length).to.equal(1);
|
|
116
|
+
const restore = reparentChildren([...children], destination, {
|
|
117
|
+
position: "beforeend"
|
|
141
118
|
});
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
119
|
+
expect(source.children.length).to.equal(0);
|
|
120
|
+
expect(destination.children.length).to.equal(5 + 1);
|
|
121
|
+
const marker = context.querySelector(".marker");
|
|
122
|
+
expect(marker.previousElementSibling).to.be.null;
|
|
123
|
+
expect((_a = marker.nextElementSibling) == null ? void 0 : _a.textContent).to.equal("1");
|
|
124
|
+
expect((_b = destination.lastElementChild) == null ? void 0 : _b.textContent).to.equal("5");
|
|
125
|
+
restore();
|
|
126
|
+
expect(source.children.length).to.equal(5);
|
|
127
|
+
expect(destination.children.length).to.equal(1);
|
|
128
|
+
expect((_c = source.firstElementChild) == null ? void 0 : _c.textContent).to.equal("1");
|
|
129
|
+
expect((_d = source.lastElementChild) == null ? void 0 : _d.textContent).to.equal("5");
|
|
130
|
+
});
|
|
131
|
+
it("afterbegin - reparents and returns multiple children", async () => {
|
|
132
|
+
var _a, _b, _c, _d;
|
|
133
|
+
const context = await fixture(html`
|
|
145
134
|
<div>
|
|
146
135
|
<div class="source">
|
|
147
136
|
<div class="child">1</div>
|
|
@@ -155,29 +144,29 @@ describe('Reparent Children', () => {
|
|
|
155
144
|
</div>
|
|
156
145
|
</div>
|
|
157
146
|
`);
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
});
|
|
166
|
-
expect(source.children.length).to.equal(0);
|
|
167
|
-
expect(destination.children.length).to.equal(5 + 1);
|
|
168
|
-
const marker = context.querySelector('.marker');
|
|
169
|
-
expect(marker.nextElementSibling).to.be.null;
|
|
170
|
-
expect((_a = marker.previousElementSibling) === null || _a === void 0 ? void 0 : _a.textContent).to.equal('5');
|
|
171
|
-
expect((_b = destination.firstElementChild) === null || _b === void 0 ? void 0 : _b.textContent).to.equal('1');
|
|
172
|
-
restore();
|
|
173
|
-
expect(source.children.length).to.equal(5);
|
|
174
|
-
expect(destination.children.length).to.equal(1);
|
|
175
|
-
expect((_c = source.firstElementChild) === null || _c === void 0 ? void 0 : _c.textContent).to.equal('1');
|
|
176
|
-
expect((_d = source.lastElementChild) === null || _d === void 0 ? void 0 : _d.textContent).to.equal('5');
|
|
147
|
+
const source = context.querySelector(".source");
|
|
148
|
+
const { children } = source;
|
|
149
|
+
const destination = context.querySelector(".destination");
|
|
150
|
+
expect(source.children.length).to.equal(5);
|
|
151
|
+
expect(destination.children.length).to.equal(1);
|
|
152
|
+
const restore = reparentChildren([...children], destination, {
|
|
153
|
+
position: "afterbegin"
|
|
177
154
|
});
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
155
|
+
expect(source.children.length).to.equal(0);
|
|
156
|
+
expect(destination.children.length).to.equal(5 + 1);
|
|
157
|
+
const marker = context.querySelector(".marker");
|
|
158
|
+
expect(marker.nextElementSibling).to.be.null;
|
|
159
|
+
expect((_a = marker.previousElementSibling) == null ? void 0 : _a.textContent).to.equal("5");
|
|
160
|
+
expect((_b = destination.firstElementChild) == null ? void 0 : _b.textContent).to.equal("1");
|
|
161
|
+
restore();
|
|
162
|
+
expect(source.children.length).to.equal(5);
|
|
163
|
+
expect(destination.children.length).to.equal(1);
|
|
164
|
+
expect((_c = source.firstElementChild) == null ? void 0 : _c.textContent).to.equal("1");
|
|
165
|
+
expect((_d = source.lastElementChild) == null ? void 0 : _d.textContent).to.equal("5");
|
|
166
|
+
});
|
|
167
|
+
it("beforebegin - reparents and returns multiple children", async () => {
|
|
168
|
+
var _a, _b, _c, _d;
|
|
169
|
+
const context = await fixture(html`
|
|
181
170
|
<div>
|
|
182
171
|
<div class="source">
|
|
183
172
|
<div class="child">1</div>
|
|
@@ -190,28 +179,28 @@ describe('Reparent Children', () => {
|
|
|
190
179
|
<div class="destination"></div>
|
|
191
180
|
</div>
|
|
192
181
|
`);
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
});
|
|
200
|
-
expect(source.children.length).to.equal(0);
|
|
201
|
-
expect(destination.children.length).to.equal(0);
|
|
202
|
-
const marker = context.querySelector('.marker');
|
|
203
|
-
expect(marker.previousElementSibling).to.not.be.null;
|
|
204
|
-
expect((_a = marker.nextElementSibling) === null || _a === void 0 ? void 0 : _a.textContent).to.equal('1');
|
|
205
|
-
expect((_b = destination.previousElementSibling) === null || _b === void 0 ? void 0 : _b.textContent).to.equal('5');
|
|
206
|
-
restore();
|
|
207
|
-
expect(source.children.length).to.equal(5);
|
|
208
|
-
expect(marker.nextElementSibling).to.equal(destination);
|
|
209
|
-
expect((_c = source.firstElementChild) === null || _c === void 0 ? void 0 : _c.textContent).to.equal('1');
|
|
210
|
-
expect((_d = source.lastElementChild) === null || _d === void 0 ? void 0 : _d.textContent).to.equal('5');
|
|
182
|
+
const source = context.querySelector(".source");
|
|
183
|
+
const { children } = source;
|
|
184
|
+
const destination = context.querySelector(".destination");
|
|
185
|
+
expect(source.children.length).to.equal(5);
|
|
186
|
+
const restore = reparentChildren([...children], destination, {
|
|
187
|
+
position: "beforebegin"
|
|
211
188
|
});
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
189
|
+
expect(source.children.length).to.equal(0);
|
|
190
|
+
expect(destination.children.length).to.equal(0);
|
|
191
|
+
const marker = context.querySelector(".marker");
|
|
192
|
+
expect(marker.previousElementSibling).to.not.be.null;
|
|
193
|
+
expect((_a = marker.nextElementSibling) == null ? void 0 : _a.textContent).to.equal("1");
|
|
194
|
+
expect((_b = destination.previousElementSibling) == null ? void 0 : _b.textContent).to.equal("5");
|
|
195
|
+
restore();
|
|
196
|
+
expect(source.children.length).to.equal(5);
|
|
197
|
+
expect(marker.nextElementSibling).to.equal(destination);
|
|
198
|
+
expect((_c = source.firstElementChild) == null ? void 0 : _c.textContent).to.equal("1");
|
|
199
|
+
expect((_d = source.lastElementChild) == null ? void 0 : _d.textContent).to.equal("5");
|
|
200
|
+
});
|
|
201
|
+
it("afterend - reparents and returns multiple children", async () => {
|
|
202
|
+
var _a, _b, _c, _d;
|
|
203
|
+
const context = await fixture(html`
|
|
215
204
|
<div>
|
|
216
205
|
<div class="source">
|
|
217
206
|
<div class="child">1</div>
|
|
@@ -224,25 +213,25 @@ describe('Reparent Children', () => {
|
|
|
224
213
|
<div class="marker"></div>
|
|
225
214
|
</div>
|
|
226
215
|
`);
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
});
|
|
237
|
-
expect(source.children.length).to.equal(0);
|
|
238
|
-
expect(destination.children.length).to.equal(0);
|
|
239
|
-
expect((_a = destination.nextElementSibling) === null || _a === void 0 ? void 0 : _a.textContent).to.equal('1');
|
|
240
|
-
expect((_b = marker.previousElementSibling) === null || _b === void 0 ? void 0 : _b.textContent).to.equal('5');
|
|
241
|
-
restore();
|
|
242
|
-
expect(source.children.length).to.equal(5);
|
|
243
|
-
expect(marker.previousElementSibling).to.equal(destination);
|
|
244
|
-
expect((_c = source.firstElementChild) === null || _c === void 0 ? void 0 : _c.textContent).to.equal('1');
|
|
245
|
-
expect((_d = source.lastElementChild) === null || _d === void 0 ? void 0 : _d.textContent).to.equal('5');
|
|
216
|
+
const source = context.querySelector(".source");
|
|
217
|
+
const { children } = source;
|
|
218
|
+
const destination = context.querySelector(".destination");
|
|
219
|
+
expect(source.children.length).to.equal(5);
|
|
220
|
+
const marker = context.querySelector(".marker");
|
|
221
|
+
expect(marker.previousElementSibling).to.equal(destination);
|
|
222
|
+
expect(marker.nextElementSibling).to.be.null;
|
|
223
|
+
const restore = reparentChildren([...children], destination, {
|
|
224
|
+
position: "afterend"
|
|
246
225
|
});
|
|
226
|
+
expect(source.children.length).to.equal(0);
|
|
227
|
+
expect(destination.children.length).to.equal(0);
|
|
228
|
+
expect((_a = destination.nextElementSibling) == null ? void 0 : _a.textContent).to.equal("1");
|
|
229
|
+
expect((_b = marker.previousElementSibling) == null ? void 0 : _b.textContent).to.equal("5");
|
|
230
|
+
restore();
|
|
231
|
+
expect(source.children.length).to.equal(5);
|
|
232
|
+
expect(marker.previousElementSibling).to.equal(destination);
|
|
233
|
+
expect((_c = source.firstElementChild) == null ? void 0 : _c.textContent).to.equal("1");
|
|
234
|
+
expect((_d = source.lastElementChild) == null ? void 0 : _d.textContent).to.equal("5");
|
|
235
|
+
});
|
|
247
236
|
});
|
|
248
|
-
//# sourceMappingURL=reparent-children.test.js.map
|
|
237
|
+
//# sourceMappingURL=reparent-children.test.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{"version":3,"file":"reparent-children.test.js","sourceRoot":"","sources":["reparent-children.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;AAEF,OAAO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,CAAC,CAAC;QAC5D,MAAM,CAAC,MAAA,MAAM,CAAC,gBAAgB,0CAAE,WAAW,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC/D,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC","sourcesContent":["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport { expect, fixture, html } from '@open-wc/testing';\nimport { reparentChildren } from '../src/reparent-children.js';\n\ndescribe('Reparent Children', () => {\n it('reparents and returns a single child', async () => {\n const context = await fixture<HTMLDivElement>(html`\n <div>\n <div class=\"source\">\n <div class=\"child\"></div>\n </div>\n <div class=\"destination\"></div>\n </div>\n `);\n\n const source = context.querySelector('.source') as HTMLDivElement;\n const child = context.querySelector('.child') as HTMLDivElement;\n const destination = context.querySelector(\n '.destination'\n ) as HTMLDivElement;\n\n expect(source.children.length).to.equal(1);\n expect(destination.children.length).to.equal(0);\n const restore = reparentChildren([child], destination);\n\n expect(source.children.length).to.equal(0);\n expect(destination.children.length).to.equal(1);\n\n restore();\n expect(source.children.length).to.equal(1);\n expect(destination.children.length).to.equal(0);\n });\n\n it('early exits no children', async () => {\n const context = await fixture<HTMLDivElement>(html`\n <div>\n <div class=\"source\"></div>\n <div class=\"destination\"></div>\n </div>\n `);\n\n const source = context.querySelector('.source') as HTMLDivElement;\n const children = [...source.children] as HTMLDivElement[];\n const destination = context.querySelector(\n '.destination'\n ) as HTMLDivElement;\n\n expect(source.children.length).to.equal(0);\n expect(destination.children.length).to.equal(0);\n const restore = reparentChildren(children, destination);\n\n expect(source.children.length).to.equal(0);\n expect(destination.children.length).to.equal(0);\n\n restore();\n expect(source.children.length).to.equal(0);\n expect(destination.children.length).to.equal(0);\n });\n\n it('reparents and returns multiple child', async () => {\n const context = await fixture<HTMLDivElement>(html`\n <div>\n <div class=\"source\">\n <div class=\"child\"></div>\n <div class=\"child\"></div>\n <div class=\"child\"></div>\n <div class=\"child\"></div>\n <div class=\"child\"></div>\n </div>\n <div class=\"destination\"></div>\n </div>\n `);\n\n const source = context.querySelector('.source') as HTMLDivElement;\n const { children } = source;\n const destination = context.querySelector(\n '.destination'\n ) as HTMLDivElement;\n\n expect(source.children.length).to.equal(5);\n expect(destination.children.length).to.equal(0);\n const restore = reparentChildren([...children], destination);\n\n expect(source.children.length).to.equal(0);\n expect(destination.children.length).to.equal(5);\n\n restore();\n expect(source.children.length).to.equal(5);\n expect(destination.children.length).to.equal(0);\n });\n\n it('augments the child via a callback', async () => {\n const context = await fixture<HTMLDivElement>(html`\n <div>\n <div class=\"source\">\n <div class=\"child\" slot=\"slot\"></div>\n </div>\n <div class=\"destination\"></div>\n </div>\n `);\n\n const child = context.querySelector('.child') as HTMLDivElement;\n const destination = context.querySelector(\n '.destination'\n ) as HTMLDivElement;\n\n expect(child.getAttribute('slot')).to.equal('slot');\n const restore = reparentChildren([child], destination, {\n position: 'beforeend',\n prepareCallback: (el: Element) => {\n const slotName = el.slot;\n el.removeAttribute('slot');\n return (el: Element) => {\n el.slot = slotName;\n };\n },\n });\n\n expect(child.hasAttribute('slot')).to.be.false;\n\n restore();\n expect(child.getAttribute('slot')).to.equal('slot');\n });\n\n it('beforeend - reparents and returns multiple children', async () => {\n const context = await fixture<HTMLDivElement>(html`\n <div>\n <div class=\"source\">\n <div class=\"child\">1</div>\n <div class=\"child\">2</div>\n <div class=\"child\">3</div>\n <div class=\"child\">4</div>\n <div class=\"child\">5</div>\n </div>\n <div class=\"destination\">\n <div class=\"marker\"></div>\n </div>\n </div>\n `);\n\n const source = context.querySelector('.source') as HTMLDivElement;\n const { children } = source;\n const destination = context.querySelector(\n '.destination'\n ) as HTMLDivElement;\n\n expect(source.children.length).to.equal(5);\n expect(destination.children.length).to.equal(1);\n const restore = reparentChildren([...children], destination, {\n position: 'beforeend',\n });\n\n expect(source.children.length).to.equal(0);\n expect(destination.children.length).to.equal(5 + 1);\n\n const marker = context.querySelector('.marker') as HTMLDivElement;\n expect(marker.previousElementSibling).to.be.null;\n expect(marker.nextElementSibling?.textContent).to.equal('1');\n expect(destination.lastElementChild?.textContent).to.equal('5');\n\n restore();\n expect(source.children.length).to.equal(5);\n expect(destination.children.length).to.equal(1);\n\n expect(source.firstElementChild?.textContent).to.equal('1');\n expect(source.lastElementChild?.textContent).to.equal('5');\n });\n\n it('afterbegin - reparents and returns multiple children', async () => {\n const context = await fixture<HTMLDivElement>(html`\n <div>\n <div class=\"source\">\n <div class=\"child\">1</div>\n <div class=\"child\">2</div>\n <div class=\"child\">3</div>\n <div class=\"child\">4</div>\n <div class=\"child\">5</div>\n </div>\n <div class=\"destination\">\n <div class=\"marker\"></div>\n </div>\n </div>\n `);\n\n const source = context.querySelector('.source') as HTMLDivElement;\n const { children } = source;\n const destination = context.querySelector(\n '.destination'\n ) as HTMLDivElement;\n\n expect(source.children.length).to.equal(5);\n expect(destination.children.length).to.equal(1);\n const restore = reparentChildren([...children], destination, {\n position: 'afterbegin',\n });\n\n expect(source.children.length).to.equal(0);\n expect(destination.children.length).to.equal(5 + 1);\n\n const marker = context.querySelector('.marker') as HTMLDivElement;\n expect(marker.nextElementSibling).to.be.null;\n expect(marker.previousElementSibling?.textContent).to.equal('5');\n expect(destination.firstElementChild?.textContent).to.equal('1');\n\n restore();\n expect(source.children.length).to.equal(5);\n expect(destination.children.length).to.equal(1);\n\n expect(source.firstElementChild?.textContent).to.equal('1');\n expect(source.lastElementChild?.textContent).to.equal('5');\n });\n\n it('beforebegin - reparents and returns multiple children', async () => {\n const context = await fixture<HTMLDivElement>(html`\n <div>\n <div class=\"source\">\n <div class=\"child\">1</div>\n <div class=\"child\">2</div>\n <div class=\"child\">3</div>\n <div class=\"child\">4</div>\n <div class=\"child\">5</div>\n </div>\n <div class=\"marker\"></div>\n <div class=\"destination\"></div>\n </div>\n `);\n\n const source = context.querySelector('.source') as HTMLDivElement;\n const { children } = source;\n const destination = context.querySelector(\n '.destination'\n ) as HTMLDivElement;\n\n expect(source.children.length).to.equal(5);\n const restore = reparentChildren([...children], destination, {\n position: 'beforebegin',\n });\n\n expect(source.children.length).to.equal(0);\n expect(destination.children.length).to.equal(0);\n\n const marker = context.querySelector('.marker') as HTMLDivElement;\n expect(marker.previousElementSibling).to.not.be.null;\n expect(marker.nextElementSibling?.textContent).to.equal('1');\n expect(destination.previousElementSibling?.textContent).to.equal('5');\n\n restore();\n expect(source.children.length).to.equal(5);\n expect(marker.nextElementSibling).to.equal(destination);\n\n expect(source.firstElementChild?.textContent).to.equal('1');\n expect(source.lastElementChild?.textContent).to.equal('5');\n });\n\n it('afterend - reparents and returns multiple children', async () => {\n const context = await fixture<HTMLDivElement>(html`\n <div>\n <div class=\"source\">\n <div class=\"child\">1</div>\n <div class=\"child\">2</div>\n <div class=\"child\">3</div>\n <div class=\"child\">4</div>\n <div class=\"child\">5</div>\n </div>\n <div class=\"destination\"></div>\n <div class=\"marker\"></div>\n </div>\n `);\n\n const source = context.querySelector('.source') as HTMLDivElement;\n const { children } = source;\n const destination = context.querySelector(\n '.destination'\n ) as HTMLDivElement;\n\n expect(source.children.length).to.equal(5);\n\n const marker = context.querySelector('.marker') as HTMLDivElement;\n expect(marker.previousElementSibling).to.equal(destination);\n expect(marker.nextElementSibling).to.be.null;\n\n const restore = reparentChildren([...children], destination, {\n position: 'afterend',\n });\n\n expect(source.children.length).to.equal(0);\n expect(destination.children.length).to.equal(0);\n\n expect(destination.nextElementSibling?.textContent).to.equal('1');\n expect(marker.previousElementSibling?.textContent).to.equal('5');\n\n restore();\n expect(source.children.length).to.equal(5);\n expect(marker.previousElementSibling).to.equal(destination);\n\n expect(source.firstElementChild?.textContent).to.equal('1');\n expect(source.lastElementChild?.textContent).to.equal('5');\n });\n});\n"]}
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["reparent-children.test.ts"],
|
|
4
|
+
"sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport { expect, fixture, html } from '@open-wc/testing';\nimport { reparentChildren } from '@spectrum-web-components/shared/src/reparent-children.js';\n\ndescribe('Reparent Children', () => {\n it('reparents and returns a single child', async () => {\n const context = await fixture<HTMLDivElement>(html`\n <div>\n <div class=\"source\">\n <div class=\"child\"></div>\n </div>\n <div class=\"destination\"></div>\n </div>\n `);\n\n const source = context.querySelector('.source') as HTMLDivElement;\n const child = context.querySelector('.child') as HTMLDivElement;\n const destination = context.querySelector(\n '.destination'\n ) as HTMLDivElement;\n\n expect(source.children.length).to.equal(1);\n expect(destination.children.length).to.equal(0);\n const restore = reparentChildren([child], destination);\n\n expect(source.children.length).to.equal(0);\n expect(destination.children.length).to.equal(1);\n\n restore();\n expect(source.children.length).to.equal(1);\n expect(destination.children.length).to.equal(0);\n });\n\n it('early exits no children', async () => {\n const context = await fixture<HTMLDivElement>(html`\n <div>\n <div class=\"source\"></div>\n <div class=\"destination\"></div>\n </div>\n `);\n\n const source = context.querySelector('.source') as HTMLDivElement;\n const children = [...source.children] as HTMLDivElement[];\n const destination = context.querySelector(\n '.destination'\n ) as HTMLDivElement;\n\n expect(source.children.length).to.equal(0);\n expect(destination.children.length).to.equal(0);\n const restore = reparentChildren(children, destination);\n\n expect(source.children.length).to.equal(0);\n expect(destination.children.length).to.equal(0);\n\n restore();\n expect(source.children.length).to.equal(0);\n expect(destination.children.length).to.equal(0);\n });\n\n it('reparents and returns multiple child', async () => {\n const context = await fixture<HTMLDivElement>(html`\n <div>\n <div class=\"source\">\n <div class=\"child\"></div>\n <div class=\"child\"></div>\n <div class=\"child\"></div>\n <div class=\"child\"></div>\n <div class=\"child\"></div>\n </div>\n <div class=\"destination\"></div>\n </div>\n `);\n\n const source = context.querySelector('.source') as HTMLDivElement;\n const { children } = source;\n const destination = context.querySelector(\n '.destination'\n ) as HTMLDivElement;\n\n expect(source.children.length).to.equal(5);\n expect(destination.children.length).to.equal(0);\n const restore = reparentChildren([...children], destination);\n\n expect(source.children.length).to.equal(0);\n expect(destination.children.length).to.equal(5);\n\n restore();\n expect(source.children.length).to.equal(5);\n expect(destination.children.length).to.equal(0);\n });\n\n it('augments the child via a callback', async () => {\n const context = await fixture<HTMLDivElement>(html`\n <div>\n <div class=\"source\">\n <div class=\"child\" slot=\"slot\"></div>\n </div>\n <div class=\"destination\"></div>\n </div>\n `);\n\n const child = context.querySelector('.child') as HTMLDivElement;\n const destination = context.querySelector(\n '.destination'\n ) as HTMLDivElement;\n\n expect(child.getAttribute('slot')).to.equal('slot');\n const restore = reparentChildren([child], destination, {\n position: 'beforeend',\n prepareCallback: (el: Element) => {\n const slotName = el.slot;\n el.removeAttribute('slot');\n return (el: Element) => {\n el.slot = slotName;\n };\n },\n });\n\n expect(child.hasAttribute('slot')).to.be.false;\n\n restore();\n expect(child.getAttribute('slot')).to.equal('slot');\n });\n\n it('beforeend - reparents and returns multiple children', async () => {\n const context = await fixture<HTMLDivElement>(html`\n <div>\n <div class=\"source\">\n <div class=\"child\">1</div>\n <div class=\"child\">2</div>\n <div class=\"child\">3</div>\n <div class=\"child\">4</div>\n <div class=\"child\">5</div>\n </div>\n <div class=\"destination\">\n <div class=\"marker\"></div>\n </div>\n </div>\n `);\n\n const source = context.querySelector('.source') as HTMLDivElement;\n const { children } = source;\n const destination = context.querySelector(\n '.destination'\n ) as HTMLDivElement;\n\n expect(source.children.length).to.equal(5);\n expect(destination.children.length).to.equal(1);\n const restore = reparentChildren([...children], destination, {\n position: 'beforeend',\n });\n\n expect(source.children.length).to.equal(0);\n expect(destination.children.length).to.equal(5 + 1);\n\n const marker = context.querySelector('.marker') as HTMLDivElement;\n expect(marker.previousElementSibling).to.be.null;\n expect(marker.nextElementSibling?.textContent).to.equal('1');\n expect(destination.lastElementChild?.textContent).to.equal('5');\n\n restore();\n expect(source.children.length).to.equal(5);\n expect(destination.children.length).to.equal(1);\n\n expect(source.firstElementChild?.textContent).to.equal('1');\n expect(source.lastElementChild?.textContent).to.equal('5');\n });\n\n it('afterbegin - reparents and returns multiple children', async () => {\n const context = await fixture<HTMLDivElement>(html`\n <div>\n <div class=\"source\">\n <div class=\"child\">1</div>\n <div class=\"child\">2</div>\n <div class=\"child\">3</div>\n <div class=\"child\">4</div>\n <div class=\"child\">5</div>\n </div>\n <div class=\"destination\">\n <div class=\"marker\"></div>\n </div>\n </div>\n `);\n\n const source = context.querySelector('.source') as HTMLDivElement;\n const { children } = source;\n const destination = context.querySelector(\n '.destination'\n ) as HTMLDivElement;\n\n expect(source.children.length).to.equal(5);\n expect(destination.children.length).to.equal(1);\n const restore = reparentChildren([...children], destination, {\n position: 'afterbegin',\n });\n\n expect(source.children.length).to.equal(0);\n expect(destination.children.length).to.equal(5 + 1);\n\n const marker = context.querySelector('.marker') as HTMLDivElement;\n expect(marker.nextElementSibling).to.be.null;\n expect(marker.previousElementSibling?.textContent).to.equal('5');\n expect(destination.firstElementChild?.textContent).to.equal('1');\n\n restore();\n expect(source.children.length).to.equal(5);\n expect(destination.children.length).to.equal(1);\n\n expect(source.firstElementChild?.textContent).to.equal('1');\n expect(source.lastElementChild?.textContent).to.equal('5');\n });\n\n it('beforebegin - reparents and returns multiple children', async () => {\n const context = await fixture<HTMLDivElement>(html`\n <div>\n <div class=\"source\">\n <div class=\"child\">1</div>\n <div class=\"child\">2</div>\n <div class=\"child\">3</div>\n <div class=\"child\">4</div>\n <div class=\"child\">5</div>\n </div>\n <div class=\"marker\"></div>\n <div class=\"destination\"></div>\n </div>\n `);\n\n const source = context.querySelector('.source') as HTMLDivElement;\n const { children } = source;\n const destination = context.querySelector(\n '.destination'\n ) as HTMLDivElement;\n\n expect(source.children.length).to.equal(5);\n const restore = reparentChildren([...children], destination, {\n position: 'beforebegin',\n });\n\n expect(source.children.length).to.equal(0);\n expect(destination.children.length).to.equal(0);\n\n const marker = context.querySelector('.marker') as HTMLDivElement;\n expect(marker.previousElementSibling).to.not.be.null;\n expect(marker.nextElementSibling?.textContent).to.equal('1');\n expect(destination.previousElementSibling?.textContent).to.equal('5');\n\n restore();\n expect(source.children.length).to.equal(5);\n expect(marker.nextElementSibling).to.equal(destination);\n\n expect(source.firstElementChild?.textContent).to.equal('1');\n expect(source.lastElementChild?.textContent).to.equal('5');\n });\n\n it('afterend - reparents and returns multiple children', async () => {\n const context = await fixture<HTMLDivElement>(html`\n <div>\n <div class=\"source\">\n <div class=\"child\">1</div>\n <div class=\"child\">2</div>\n <div class=\"child\">3</div>\n <div class=\"child\">4</div>\n <div class=\"child\">5</div>\n </div>\n <div class=\"destination\"></div>\n <div class=\"marker\"></div>\n </div>\n `);\n\n const source = context.querySelector('.source') as HTMLDivElement;\n const { children } = source;\n const destination = context.querySelector(\n '.destination'\n ) as HTMLDivElement;\n\n expect(source.children.length).to.equal(5);\n\n const marker = context.querySelector('.marker') as HTMLDivElement;\n expect(marker.previousElementSibling).to.equal(destination);\n expect(marker.nextElementSibling).to.be.null;\n\n const restore = reparentChildren([...children], destination, {\n position: 'afterend',\n });\n\n expect(source.children.length).to.equal(0);\n expect(destination.children.length).to.equal(0);\n\n expect(destination.nextElementSibling?.textContent).to.equal('1');\n expect(marker.previousElementSibling?.textContent).to.equal('5');\n\n restore();\n expect(source.children.length).to.equal(5);\n expect(marker.previousElementSibling).to.equal(destination);\n\n expect(source.firstElementChild?.textContent).to.equal('1');\n expect(source.lastElementChild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