@spectrum-web-components/shared 0.13.6 → 0.13.7

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spectrum-web-components/shared",
3
- "version": "0.13.6",
3
+ "version": "0.13.7",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -49,5 +49,5 @@
49
49
  "types": "./src/index.d.ts",
50
50
  "customElements": "custom-elements.json",
51
51
  "sideEffects": false,
52
- "gitHead": "caf12727e7f91dcf961e1fadacc727eea9ece27b"
52
+ "gitHead": "dd76f9532fdea946880147cc7645f113b998c326"
53
53
  }
@@ -14,7 +14,6 @@ interface OptionalLifecycleCallbacks {
14
14
  manageAutoFocus?(): void;
15
15
  }
16
16
  declare type MixableBaseClass = HTMLElement & OptionalLifecycleCallbacks;
17
- import 'focus-visible';
18
17
  /**
19
18
  * This mixin function is designed to be applied to a class that inherits
20
19
  * from HTMLElement. It makes it easy for a custom element to coordinate with
@@ -10,7 +10,6 @@ OF ANY KIND, either express or implied. See the License for the specific languag
10
10
  governing permissions and limitations under the License.
11
11
  */
12
12
  import 'focus-visible';
13
- import 'focus-visible';
14
13
  let hasFocusVisible = true;
15
14
  try {
16
15
  document.body.querySelector(':focus-visible');
@@ -86,7 +85,8 @@ export const FocusVisiblePolyfillMixin = (SuperClass) => {
86
85
  if (!hasFocusVisible) {
87
86
  requestAnimationFrame(() => {
88
87
  if (this[$endPolyfillCoordination] == null) {
89
- this[$endPolyfillCoordination] = coordinateWithPolyfill(this);
88
+ this[$endPolyfillCoordination] =
89
+ coordinateWithPolyfill(this);
90
90
  }
91
91
  });
92
92
  }
@@ -1 +1 @@
1
- {"version":3,"file":"focus-visible.js","sourceRoot":"","sources":["focus-visible.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;AAEF,OAAO,eAAe,CAAC;AAwBvB,OAAO,eAAe,CAAC;AAEvB,I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BAA8B,EAC9B,mBAAmB,CACtB,CAAC;YACN,CAAC,CAAC;SACL;QAED,gEAAgE;QAChE,OAAO,GAAG,EAAE,GAAE,CAAC,CAAC;IACpB,CAAC,CAAC;IAEF,MAAM,wBAAwB,GAAG,MAAM,CAAC,yBAAyB,CAAC,CAAC;IAEnE,oEAAoE;IACpE,sEAAsE;IACtE,qCAAqC;IACrC,MAAM,uBAAwB,SAAQ,UAAU;QAAhD;;YACY,QAA0B,GAA2C,IAAI,CAAC;QA+BtF,CAAC;QA7BG,gEAAgE;QAChE,YAAY;QACZ,iBAAiB;YACb,KAAK,CAAC,iBAAiB,IAAI,KAAK,CAAC,iBAAiB,EAAE,CAAC;YACrD,IAAI,CAAC,eAAe,EAAE;gBAClB,qBAAqB,CAAC,GAAG,EAAE;oBACvB,IAAI,IAAI,CAAC,wBAAwB,CAAC,IAAI,IAAI,EAAE;wBACxC,IAAI,CAAC,wBAAwB,CAAC,GAAG,sBAAsB,CACnD,IAAI,CACP,CAAC;qBACL;gBACL,CAAC,CAAC,CAAC;aACN;QACL,CAAC;QAED,oBAAoB;YAChB,KAAK,CAAC,oBAAoB,IAAI,KAAK,CAAC,oBAAoB,EAAE,CAAC;YAC3D,+DAA+D;YAC/D,mEAAmE;YACnE,IAAI,CAAC,eAAe,EAAE;gBAClB,qBAAqB,CAAC,GAAG,EAAE;oBACvB,IAAI,IAAI,CAAC,wBAAwB,CAAC,IAAI,IAAI,EAAE;wBACxC,oEAAoE;wBACpE,IAAI,CAAC,wBAAwB,CAAE,EAAE,CAAC;wBAClC,IAAI,CAAC,wBAAwB,CAAC,GAAG,IAAI,CAAC;qBACzC;gBACL,CAAC,CAAC,CAAC;aACN;QACL,CAAC;KACJ;SA/BY,wBAAwB;IAiCrC,OAAO,uBAAuB,CAAC;AACnC,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 'focus-visible';\n\ndeclare global {\n interface Window {\n applyFocusVisiblePolyfill?: (scope: Document | ShadowRoot) => void;\n }\n}\n\ntype Constructor<T = Record<string, unknown>> = {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n new (...args: any[]): T;\n prototype: T;\n};\n\ninterface OptionalLifecycleCallbacks {\n connectedCallback?(): void;\n disconnectedCallback?(): void;\n manageAutoFocus?(): void;\n}\n\ntype MixableBaseClass = HTMLElement & OptionalLifecycleCallbacks;\n\ntype EndPolyfillCoordinationCallback = () => void;\n\nimport 'focus-visible';\n\nlet hasFocusVisible = true;\n\ntry {\n document.body.querySelector(':focus-visible');\n} catch (error) {\n hasFocusVisible = false;\n}\n\n/**\n * This mixin function is designed to be applied to a class that inherits\n * from HTMLElement. It makes it easy for a custom element to coordinate with\n * the :focus-visible polyfill.\n *\n * NOTE(cdata): The code here was adapted from an example proposed with the\n * introduction of ShadowDOM support in the :focus-visible polyfill.\n *\n * @see https://github.com/WICG/focus-visible/pull/196\n * @param {Function} SuperClass The base class implementation to decorate with\n * implementation that coordinates with the :focus-visible polyfill\n */\nexport const FocusVisiblePolyfillMixin = <\n T extends Constructor<MixableBaseClass>\n>(\n SuperClass: T\n): T => {\n const coordinateWithPolyfill = (\n instance: MixableBaseClass\n ): EndPolyfillCoordinationCallback => {\n // If there is no shadow root, there is no need to coordinate with\n // the polyfill. If we already coordinated with the polyfill, we can\n // skip subsequent invokcations:\n if (\n instance.shadowRoot == null ||\n instance.hasAttribute('data-js-focus-visible')\n ) {\n // eslint-disable-next-line @typescript-eslint/no-empty-function\n return () => {};\n }\n\n // The polyfill might already be loaded. If so, we can apply it to\n // the shadow root immediately:\n if (self.applyFocusVisiblePolyfill) {\n self.applyFocusVisiblePolyfill(instance.shadowRoot);\n\n if (instance.manageAutoFocus) {\n instance.manageAutoFocus();\n }\n } else {\n const coordinationHandler = (): void => {\n if (self.applyFocusVisiblePolyfill && instance.shadowRoot) {\n self.applyFocusVisiblePolyfill(instance.shadowRoot);\n }\n\n if (instance.manageAutoFocus) {\n instance.manageAutoFocus();\n }\n };\n // Otherwise, wait for the polyfill to be loaded lazily. It might\n // never be loaded, but if it is then we can apply it to the\n // shadow root at the appropriate time by waiting for the ready\n // event:\n self.addEventListener(\n 'focus-visible-polyfill-ready',\n coordinationHandler,\n { once: true }\n );\n\n return () => {\n self.removeEventListener(\n 'focus-visible-polyfill-ready',\n coordinationHandler\n );\n };\n }\n\n // eslint-disable-next-line @typescript-eslint/no-empty-function\n return () => {};\n };\n\n const $endPolyfillCoordination = Symbol('endPolyfillCoordination');\n\n // IE11 doesn't natively support custom elements or JavaScript class\n // syntax The mixin implementation assumes that the user will take the\n // appropriate steps to support both:\n class FocusVisibleCoordinator extends SuperClass {\n private [$endPolyfillCoordination]: EndPolyfillCoordinationCallback | null = null;\n\n // Attempt to coordinate with the polyfill when connected to the\n // document:\n connectedCallback(): void {\n super.connectedCallback && super.connectedCallback();\n if (!hasFocusVisible) {\n requestAnimationFrame(() => {\n if (this[$endPolyfillCoordination] == null) {\n this[$endPolyfillCoordination] = coordinateWithPolyfill(\n this\n );\n }\n });\n }\n }\n\n disconnectedCallback(): void {\n super.disconnectedCallback && super.disconnectedCallback();\n // It's important to remove the polyfill event listener when we\n // disconnect, otherwise we will leak the whole element via window:\n if (!hasFocusVisible) {\n requestAnimationFrame(() => {\n if (this[$endPolyfillCoordination] != null) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n this[$endPolyfillCoordination]!();\n this[$endPolyfillCoordination] = null;\n }\n });\n }\n }\n }\n\n return FocusVisibleCoordinator;\n};\n"]}
1
+ {"version":3,"file":"focus-visible.js","sourceRoot":"","sources":["focus-visible.ts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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 'focus-visible';\n\ndeclare global {\n interface Window {\n applyFocusVisiblePolyfill?: (scope: Document | ShadowRoot) => void;\n }\n}\n\ntype Constructor<T = Record<string, unknown>> = {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n new (...args: any[]): T;\n prototype: T;\n};\n\ninterface OptionalLifecycleCallbacks {\n connectedCallback?(): void;\n disconnectedCallback?(): void;\n manageAutoFocus?(): void;\n}\n\ntype MixableBaseClass = HTMLElement & OptionalLifecycleCallbacks;\n\ntype EndPolyfillCoordinationCallback = () => void;\n\nlet hasFocusVisible = true;\n\ntry {\n document.body.querySelector(':focus-visible');\n} catch (error) {\n hasFocusVisible = false;\n}\n\n/**\n * This mixin function is designed to be applied to a class that inherits\n * from HTMLElement. It makes it easy for a custom element to coordinate with\n * the :focus-visible polyfill.\n *\n * NOTE(cdata): The code here was adapted from an example proposed with the\n * introduction of ShadowDOM support in the :focus-visible polyfill.\n *\n * @see https://github.com/WICG/focus-visible/pull/196\n * @param {Function} SuperClass The base class implementation to decorate with\n * implementation that coordinates with the :focus-visible polyfill\n */\nexport const FocusVisiblePolyfillMixin = <\n T extends Constructor<MixableBaseClass>\n>(\n SuperClass: T\n): T => {\n const coordinateWithPolyfill = (\n instance: MixableBaseClass\n ): EndPolyfillCoordinationCallback => {\n // If there is no shadow root, there is no need to coordinate with\n // the polyfill. If we already coordinated with the polyfill, we can\n // skip subsequent invokcations:\n if (\n instance.shadowRoot == null ||\n instance.hasAttribute('data-js-focus-visible')\n ) {\n // eslint-disable-next-line @typescript-eslint/no-empty-function\n return () => {};\n }\n\n // The polyfill might already be loaded. If so, we can apply it to\n // the shadow root immediately:\n if (self.applyFocusVisiblePolyfill) {\n self.applyFocusVisiblePolyfill(instance.shadowRoot);\n\n if (instance.manageAutoFocus) {\n instance.manageAutoFocus();\n }\n } else {\n const coordinationHandler = (): void => {\n if (self.applyFocusVisiblePolyfill && instance.shadowRoot) {\n self.applyFocusVisiblePolyfill(instance.shadowRoot);\n }\n\n if (instance.manageAutoFocus) {\n instance.manageAutoFocus();\n }\n };\n // Otherwise, wait for the polyfill to be loaded lazily. It might\n // never be loaded, but if it is then we can apply it to the\n // shadow root at the appropriate time by waiting for the ready\n // event:\n self.addEventListener(\n 'focus-visible-polyfill-ready',\n coordinationHandler,\n { once: true }\n );\n\n return () => {\n self.removeEventListener(\n 'focus-visible-polyfill-ready',\n coordinationHandler\n );\n };\n }\n\n // eslint-disable-next-line @typescript-eslint/no-empty-function\n return () => {};\n };\n\n const $endPolyfillCoordination = Symbol('endPolyfillCoordination');\n\n // IE11 doesn't natively support custom elements or JavaScript class\n // syntax The mixin implementation assumes that the user will take the\n // appropriate steps to support both:\n class FocusVisibleCoordinator extends SuperClass {\n private [$endPolyfillCoordination]: EndPolyfillCoordinationCallback | null =\n null;\n\n // Attempt to coordinate with the polyfill when connected to the\n // document:\n connectedCallback(): void {\n super.connectedCallback && super.connectedCallback();\n if (!hasFocusVisible) {\n requestAnimationFrame(() => {\n if (this[$endPolyfillCoordination] == null) {\n this[$endPolyfillCoordination] =\n coordinateWithPolyfill(this);\n }\n });\n }\n }\n\n disconnectedCallback(): void {\n super.disconnectedCallback && super.disconnectedCallback();\n // It's important to remove the polyfill event listener when we\n // disconnect, otherwise we will leak the whole element via window:\n if (!hasFocusVisible) {\n requestAnimationFrame(() => {\n if (this[$endPolyfillCoordination] != null) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n this[$endPolyfillCoordination]!();\n this[$endPolyfillCoordination] = null;\n }\n });\n }\n }\n }\n\n return FocusVisibleCoordinator;\n};\n"]}
@@ -0,0 +1,34 @@
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
@@ -0,0 +1 @@
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"]}
@@ -0,0 +1,34 @@
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
@@ -0,0 +1 @@
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"]}
@@ -0,0 +1,35 @@
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
@@ -0,0 +1 @@
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"]}
@@ -0,0 +1,85 @@
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
@@ -0,0 +1 @@
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,CAAm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,MAAM,CAAC,CAAC;YAC3B,OAAO,CAAC,EAAW,EAAE,EAAE;gBACnB,EAAE,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"]}