@spectrum-web-components/shared 0.13.0 → 0.13.1
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 +3 -3
- package/test/focusable.test.js +0 -34
- package/test/focusable.test.js.map +0 -1
- package/test/observe-slot-presence.test.js +0 -34
- package/test/observe-slot-presence.test.js.map +0 -1
- package/test/observe-slot-text.test.js +0 -35
- package/test/observe-slot-text.test.js.map +0 -1
- package/test/reparent-children.test.js +0 -85
- package/test/reparent-children.test.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spectrum-web-components/shared",
|
|
3
|
-
"version": "0.13.
|
|
3
|
+
"version": "0.13.1",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -42,12 +42,12 @@
|
|
|
42
42
|
"lit-html"
|
|
43
43
|
],
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@spectrum-web-components/base": "^0.5.
|
|
45
|
+
"@spectrum-web-components/base": "^0.5.1",
|
|
46
46
|
"focus-visible": "^5.1.0",
|
|
47
47
|
"tslib": "^2.0.0"
|
|
48
48
|
},
|
|
49
49
|
"types": "./src/index.d.ts",
|
|
50
50
|
"customElements": "custom-elements.json",
|
|
51
51
|
"sideEffects": false,
|
|
52
|
-
"gitHead": "
|
|
52
|
+
"gitHead": "df3f333ee26a45f9fc247716b6e8ef051dca630b"
|
|
53
53
|
}
|
package/test/focusable.test.js
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright 2020 Adobe. All rights reserved.
|
|
3
|
-
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
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 '../src/focusable.js';
|
|
13
|
-
import { Focusable } from '../src/focusable.js';
|
|
14
|
-
import { elementUpdated, expect, fixture, html } from '@open-wc/testing';
|
|
15
|
-
describe('Focusable', () => {
|
|
16
|
-
it('enforces the presense of a `focusElement`', async () => {
|
|
17
|
-
customElements.define('focusable-test', class extends Focusable {
|
|
18
|
-
});
|
|
19
|
-
try {
|
|
20
|
-
const el = await fixture(html `
|
|
21
|
-
<focusable-test></focusable-test>
|
|
22
|
-
`);
|
|
23
|
-
await elementUpdated(el);
|
|
24
|
-
const focusEl = el.focusElement;
|
|
25
|
-
expect(focusEl).to.exist;
|
|
26
|
-
}
|
|
27
|
-
catch (error) {
|
|
28
|
-
expect(() => {
|
|
29
|
-
throw error;
|
|
30
|
-
}).to.throw('Must implement focusElement getter!');
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
});
|
|
34
|
-
//# sourceMappingURL=focusable.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"focusable.test.js","sourceRoot":"","sources":["focusable.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;AAEF,OAAO,qBAAqB,CAAC;AAC7B,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAEzE,QAAQ,CAAC,WAAW,EAAE,GAAG,EAAE;IACvB,EAAE,CAAC,2CAA2C,EAAE,KAAK,IAAI,EAAE;QACvD,cAAc,CAAC,MAAM,CAAC,gBAAgB,EAAE,KAAM,SAAQ,SAAS;SAAG,CAAC,CAAC;QACpE,IAAI;YACA,MAAM,EAAE,GAAG,MAAM,OAAO,CACpB,IAAI,CAAA;;iBAEH,CACJ,CAAC;YACF,MAAM,cAAc,CAAC,EAAE,CAAC,CAAC;YACzB,MAAM,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC;YAChC,MAAM,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC;SAC5B;QAAC,OAAO,KAAK,EAAE;YACZ,MAAM,CAAC,GAAG,EAAE;gBACR,MAAM,KAAK,CAAC;YAChB,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,qCAAqC,CAAC,CAAC;SACtD;IACL,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 '../src/focusable.js';\nimport { Focusable } from '../src/focusable.js';\nimport { elementUpdated, expect, fixture, html } from '@open-wc/testing';\n\ndescribe('Focusable', () => {\n it('enforces the presense of a `focusElement`', async () => {\n customElements.define('focusable-test', class extends Focusable {});\n try {\n const el = await fixture<Focusable>(\n html`\n <focusable-test></focusable-test>\n `\n );\n await elementUpdated(el);\n const focusEl = el.focusElement;\n expect(focusEl).to.exist;\n } catch (error) {\n expect(() => {\n throw error;\n }).to.throw('Must implement focusElement getter!');\n }\n });\n});\n"]}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright 2020 Adobe. All rights reserved.
|
|
3
|
-
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
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';
|
|
14
|
-
class ObserverTest extends ObserveSlotPresence(LitElement, '[slot="test-slot"]') {
|
|
15
|
-
render() {
|
|
16
|
-
return html `
|
|
17
|
-
Test Element
|
|
18
|
-
`;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
customElements.define('observe-presence-test', ObserverTest);
|
|
22
|
-
describe('ObserveSlotPresence', () => {
|
|
23
|
-
it('does no management when slot unavailable', async () => {
|
|
24
|
-
const el = await fixture(html `
|
|
25
|
-
<observe-presence-test></observe-presence-test>
|
|
26
|
-
`);
|
|
27
|
-
await elementUpdated(el);
|
|
28
|
-
expect(el.slotContentIsPresent).to.be.false;
|
|
29
|
-
el.innerHTML = '<div slot="test-slot"></div>';
|
|
30
|
-
await elementUpdated(el);
|
|
31
|
-
expect(el.slotContentIsPresent).to.be.true;
|
|
32
|
-
});
|
|
33
|
-
});
|
|
34
|
-
//# sourceMappingURL=observe-slot-presence.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"observe-slot-presence.test.js","sourceRoot":"","sources":["observe-slot-presence.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;EASE;AAEF,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AACtE,OAAO,EAAE,UAAU,EAAkB,MAAM,+BAA+B,CAAC;AAC3E,OAAO,EAAE,cAAc,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAEzE,MAAM,YAAa,SAAQ,mBAAmB,CAC1C,UAAU,EACV,oBAAoB,CACvB;IACa,MAAM;QACZ,OAAO,IAAI,CAAA;;SAEV,CAAC;IACN,CAAC;CACJ;AAED,cAAc,CAAC,MAAM,CAAC,uBAAuB,EAAE,YAAY,CAAC,CAAC;AAE7D,QAAQ,CAAC,qBAAqB,EAAE,GAAG,EAAE;IACjC,EAAE,CAAC,0CAA0C,EAAE,KAAK,IAAI,EAAE;QACtD,MAAM,EAAE,GAAG,MAAM,OAAO,CACpB,IAAI,CAAA;;aAEH,CACJ,CAAC;QACF,MAAM,cAAc,CAAC,EAAE,CAAC,CAAC;QAEzB,MAAM,CAAC,EAAE,CAAC,oBAAoB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,CAAC;QAE5C,EAAE,CAAC,SAAS,GAAG,8BAA8B,CAAC;QAC9C,MAAM,cAAc,CAAC,EAAE,CAAC,CAAC;QAEzB,MAAM,CAAC,EAAE,CAAC,oBAAoB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC;IAC/C,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\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 '../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 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"]}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright 2020 Adobe. All rights reserved.
|
|
3
|
-
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
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';
|
|
15
|
-
class ObserverTest extends ObserveSlotText(LitElement) {
|
|
16
|
-
render() {
|
|
17
|
-
return html `
|
|
18
|
-
<slot @slotchange=${this.manageTextObservedSlot}></slot>
|
|
19
|
-
`;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
customElements.define('observe-slot-test', ObserverTest);
|
|
23
|
-
describe('ObserveSlotText', () => {
|
|
24
|
-
it('does no management when slot unavailable', async () => {
|
|
25
|
-
const el = await fixture(html `
|
|
26
|
-
<observe-slot-test></observe-slot-test>
|
|
27
|
-
`);
|
|
28
|
-
await elementUpdated(el);
|
|
29
|
-
expect(el.slotHasContent).to.be.false;
|
|
30
|
-
el.textContent = `hi, i'm some text`;
|
|
31
|
-
await elementUpdated(el);
|
|
32
|
-
expect(el.slotHasContent).to.be.true;
|
|
33
|
-
});
|
|
34
|
-
});
|
|
35
|
-
//# sourceMappingURL=observe-slot-text.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"observe-slot-text.test.js","sourceRoot":"","sources":["observe-slot-text.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;AAEF,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAE,UAAU,EAAkB,MAAM,+BAA+B,CAAC;AAC3E,OAAO,EAAE,cAAc,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAEzE,MAAM,YAAa,SAAQ,eAAe,CAAC,UAAU,CAAC;IACxC,MAAM;QACZ,OAAO,IAAI,CAAA;gCACa,IAAI,CAAC,sBAAsB;SAClD,CAAC;IACN,CAAC;CACJ;AAED,cAAc,CAAC,MAAM,CAAC,mBAAmB,EAAE,YAAY,CAAC,CAAC;AAEzD,QAAQ,CAAC,iBAAiB,EAAE,GAAG,EAAE;IAC7B,EAAE,CAAC,0CAA0C,EAAE,KAAK,IAAI,EAAE;QACtD,MAAM,EAAE,GAAG,MAAM,OAAO,CACpB,IAAI,CAAA;;aAEH,CACJ,CAAC;QACF,MAAM,cAAc,CAAC,EAAE,CAAC,CAAC;QAEzB,MAAM,CAAC,EAAE,CAAC,cAAc,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,CAAC;QAEtC,EAAE,CAAC,WAAW,GAAG,mBAAmB,CAAC;QAErC,MAAM,cAAc,CAAC,EAAE,CAAC,CAAC;QAEzB,MAAM,CAAC,EAAE,CAAC,cAAc,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC;IACzC,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 { ObserveSlotText } from '../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 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"]}
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright 2020 Adobe. All rights reserved.
|
|
3
|
-
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
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 { 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 `
|
|
17
|
-
<div>
|
|
18
|
-
<div class="source">
|
|
19
|
-
<div class="child"></div>
|
|
20
|
-
</div>
|
|
21
|
-
<div class="destination"></div>
|
|
22
|
-
</div>
|
|
23
|
-
`);
|
|
24
|
-
const source = context.querySelector('.source');
|
|
25
|
-
const child = context.querySelector('.child');
|
|
26
|
-
const destination = context.querySelector('.destination');
|
|
27
|
-
expect(source.children.length).to.equal(1);
|
|
28
|
-
expect(destination.children.length).to.equal(0);
|
|
29
|
-
const restore = reparentChildren([child], destination);
|
|
30
|
-
expect(source.children.length).to.equal(0);
|
|
31
|
-
expect(destination.children.length).to.equal(1);
|
|
32
|
-
restore();
|
|
33
|
-
expect(source.children.length).to.equal(1);
|
|
34
|
-
expect(destination.children.length).to.equal(0);
|
|
35
|
-
});
|
|
36
|
-
it('reparents and returns multiple child', async () => {
|
|
37
|
-
const context = await fixture(html `
|
|
38
|
-
<div>
|
|
39
|
-
<div class="source">
|
|
40
|
-
<div class="child"></div>
|
|
41
|
-
<div class="child"></div>
|
|
42
|
-
<div class="child"></div>
|
|
43
|
-
<div class="child"></div>
|
|
44
|
-
<div class="child"></div>
|
|
45
|
-
</div>
|
|
46
|
-
<div class="destination"></div>
|
|
47
|
-
</div>
|
|
48
|
-
`);
|
|
49
|
-
const source = context.querySelector('.source');
|
|
50
|
-
const { children } = source;
|
|
51
|
-
const destination = context.querySelector('.destination');
|
|
52
|
-
expect(source.children.length).to.equal(5);
|
|
53
|
-
expect(destination.children.length).to.equal(0);
|
|
54
|
-
const restore = reparentChildren([...children], destination);
|
|
55
|
-
expect(source.children.length).to.equal(0);
|
|
56
|
-
expect(destination.children.length).to.equal(5);
|
|
57
|
-
restore();
|
|
58
|
-
expect(source.children.length).to.equal(5);
|
|
59
|
-
expect(destination.children.length).to.equal(0);
|
|
60
|
-
});
|
|
61
|
-
it('augments the child via a callback', async () => {
|
|
62
|
-
const context = await fixture(html `
|
|
63
|
-
<div>
|
|
64
|
-
<div class="source">
|
|
65
|
-
<div class="child" slot="slot"></div>
|
|
66
|
-
</div>
|
|
67
|
-
<div class="destination"></div>
|
|
68
|
-
</div>
|
|
69
|
-
`);
|
|
70
|
-
const child = context.querySelector('.child');
|
|
71
|
-
const destination = context.querySelector('.destination');
|
|
72
|
-
expect(child.getAttribute('slot')).to.equal('slot');
|
|
73
|
-
const restore = reparentChildren([child], destination, (el) => {
|
|
74
|
-
const slotName = el.slot;
|
|
75
|
-
el.removeAttribute('slot');
|
|
76
|
-
return (el) => {
|
|
77
|
-
el.slot = slotName;
|
|
78
|
-
};
|
|
79
|
-
});
|
|
80
|
-
expect(child.hasAttribute('slot')).to.be.false;
|
|
81
|
-
restore();
|
|
82
|
-
expect(child.getAttribute('slot')).to.equal('slot');
|
|
83
|
-
});
|
|
84
|
-
});
|
|
85
|
-
//# sourceMappingURL=reparent-children.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"reparent-children.test.js","sourceRoot":"","sources":["reparent-children.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;AAEF,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAE/D,QAAQ,CAAC,mBAAmB,EAAE,GAAG,EAAE;IAC/B,EAAE,CAAC,sCAAsC,EAAE,KAAK,IAAI,EAAE;QAClD,MAAM,OAAO,GAAG,MAAM,OAAO,CAAiB,IAAI,CAAA;;;;;;;SAOjD,CAAC,CAAC;QAEH,MAAM,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,SAAS,CAAmB,CAAC;QAClE,MAAM,KAAK,GAAG,OAAO,CAAC,aAAa,CAAC,QAAQ,CAAmB,CAAC;QAChE,MAAM,WAAW,GAAG,OAAO,CAAC,aAAa,CACrC,cAAc,CAC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AAE,CAAC,IAAI,GAAG,QAAQ,CAAC;YACvB,CAAC,CAAC;QACN,CAAC,CACJ,CAAC;QAEF,MAAM,CAAC,KAAK,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,CAAC;QAE/C,OAAO,EAAE,CAAC;QACV,MAAM,CAAC,KAAK,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IACxD,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('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(\n [child],\n destination,\n (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"]}
|