@spectrum-web-components/shared 0.13.0 → 0.13.3

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.0",
3
+ "version": "0.13.3",
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.0",
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": "7ce77352f6894043bceac9ef92b21e5f85420969"
52
+ "gitHead": "279380c6d72c0819fe224b405844af9ddcb87f8a"
53
53
  }
@@ -9,6 +9,7 @@ the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTA
9
9
  OF ANY KIND, either express or implied. See the License for the specific language
10
10
  governing permissions and limitations under the License.
11
11
  */
12
+ /* c8 ignore next 3 */
12
13
  export const getActiveElement = (el) => {
13
14
  return el.getRootNode().activeElement;
14
15
  };
@@ -1 +1 @@
1
- {"version":3,"file":"get-active-element.js","sourceRoot":"","sources":["get-active-element.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;AAEF,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,EAAQ,EAAkB,EAAE;IACzD,OAAQ,EAAE,CAAC,WAAW,EAAe,CAAC,aAAa,CAAC;AACxD,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\nexport const getActiveElement = (el: Node): Element | null => {\n return (el.getRootNode() as Document).activeElement;\n};\n"]}
1
+ {"version":3,"file":"get-active-element.js","sourceRoot":"","sources":["get-active-element.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;AAEF,sBAAsB;AACtB,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,EAAQ,EAAkB,EAAE;IACzD,OAAQ,EAAE,CAAC,WAAW,EAAe,CAAC,aAAa,CAAC;AACxD,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\n/* c8 ignore next 3 */\nexport const getActiveElement = (el: Node): Element | null => {\n return (el.getRootNode() as Document).activeElement;\n};\n"]}
package/src/index.d.ts CHANGED
@@ -5,4 +5,5 @@ export * from './get-active-element.js';
5
5
  export * from './like-anchor.js';
6
6
  export * from './observe-slot-presence.js';
7
7
  export * from './observe-slot-text.js';
8
+ export * from './platform.js';
8
9
  export * from './reparent-children.js';
package/src/index.js CHANGED
@@ -16,5 +16,6 @@ export * from './get-active-element.js';
16
16
  export * from './like-anchor.js';
17
17
  export * from './observe-slot-presence.js';
18
18
  export * from './observe-slot-text.js';
19
+ export * from './platform.js';
19
20
  export * from './reparent-children.js';
20
21
  //# sourceMappingURL=index.js.map
package/src/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;AAEF,cAAc,yBAAyB,CAAC;AACxC,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,yBAAyB,CAAC;AACxC,cAAc,kBAAkB,CAAC;AACjC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,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\nexport * from './first-focusable-in.js';\nexport * from './focus-visible.js';\nexport * from './focusable.js';\nexport * from './get-active-element.js';\nexport * from './like-anchor.js';\nexport * from './observe-slot-presence.js';\nexport * from './observe-slot-text.js';\nexport * from './reparent-children.js';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;AAEF,cAAc,yBAAyB,CAAC;AACxC,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,yBAAyB,CAAC;AACxC,cAAc,kBAAkB,CAAC;AACjC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,wBAAwB,CAAC;AACvC,cAAc,eAAe,CAAC;AAC9B,cAAc,wBAAwB,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\nexport * from './first-focusable-in.js';\nexport * from './focus-visible.js';\nexport * from './focusable.js';\nexport * from './get-active-element.js';\nexport * from './like-anchor.js';\nexport * from './observe-slot-presence.js';\nexport * from './observe-slot-text.js';\nexport * from './platform.js';\nexport * from './reparent-children.js';\n"]}
@@ -0,0 +1,8 @@
1
+ export declare function isMac(): boolean;
2
+ export declare function isIPhone(): boolean;
3
+ export declare function isIPad(): boolean;
4
+ export declare function isIOS(): boolean;
5
+ export declare function isAppleDevice(): boolean;
6
+ export declare function isWebKit(): boolean;
7
+ export declare function isChrome(): boolean;
8
+ export declare function isAndroid(): boolean;
@@ -0,0 +1,52 @@
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
+ function testUserAgent(re) {
13
+ return typeof window !== 'undefined' && window.navigator != null
14
+ ? re.test(window.navigator.userAgent)
15
+ : false;
16
+ }
17
+ function testPlatform(re) {
18
+ return typeof window !== 'undefined' && window.navigator != null
19
+ ? re.test(window.navigator.platform)
20
+ : false;
21
+ }
22
+ /* c8 ignore next 3 */
23
+ export function isMac() {
24
+ return testPlatform(/^Mac/);
25
+ }
26
+ export function isIPhone() {
27
+ return testPlatform(/^iPhone/);
28
+ }
29
+ export function isIPad() {
30
+ return (testPlatform(/^iPad/) ||
31
+ // iPadOS 13 lies and says it's a Mac, but we can distinguish by detecting touch support.
32
+ (isMac() && navigator.maxTouchPoints > 1));
33
+ }
34
+ export function isIOS() {
35
+ return isIPhone() || isIPad();
36
+ }
37
+ /* c8 ignore next 3 */
38
+ export function isAppleDevice() {
39
+ return isMac() || isIOS();
40
+ }
41
+ /* c8 ignore next 3 */
42
+ export function isWebKit() {
43
+ return testUserAgent(/AppleWebKit/) && !isChrome();
44
+ }
45
+ /* c8 ignore next 3 */
46
+ export function isChrome() {
47
+ return testUserAgent(/Chrome/);
48
+ }
49
+ export function isAndroid() {
50
+ return testUserAgent(/Android/);
51
+ }
52
+ //# sourceMappingURL=platform.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"platform.js","sourceRoot":"","sources":["platform.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;EAUE;AAEF,SAAS,aAAa,CAAC,EAAU;IAC7B,OAAO,OAAO,MAAM,KAAK,WAAW,IAAI,MAAM,CAAC,SAAS,IAAI,IAAI;QAC5D,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,SAAS,CAAC;QACrC,CAAC,CAAC,KAAK,CAAC;AAChB,CAAC;AAED,SAAS,YAAY,CAAC,EAAU;IAC5B,OAAO,OAAO,MAAM,KAAK,WAAW,IAAI,MAAM,CAAC,SAAS,IAAI,IAAI;QAC5D,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC;QACpC,CAAC,CAAC,KAAK,CAAC;AAChB,CAAC;AAED,sBAAsB;AACtB,MAAM,UAAU,KAAK;IACjB,OAAO,YAAY,CAAC,MAAM,CAAC,CAAC;AAChC,CAAC;AAED,MAAM,UAAU,QAAQ;IACpB,OAAO,YAAY,CAAC,SAAS,CAAC,CAAC;AACnC,CAAC;AAED,MAAM,UAAU,MAAM;IAClB,OAAO,CACH,YAAY,CAAC,OAAO,CAAC;QACrB,yFAAyF;QACzF,CAAC,KAAK,EAAE,IAAI,SAAS,CAAC,cAAc,GAAG,CAAC,CAAC,CAC5C,CAAC;AACN,CAAC;AAED,MAAM,UAAU,KAAK;IACjB,OAAO,QAAQ,EAAE,IAAI,MAAM,EAAE,CAAC;AAClC,CAAC;AAED,sBAAsB;AACtB,MAAM,UAAU,aAAa;IACzB,OAAO,KAAK,EAAE,IAAI,KAAK,EAAE,CAAC;AAC9B,CAAC;AAED,sBAAsB;AACtB,MAAM,UAAU,QAAQ;IACpB,OAAO,aAAa,CAAC,aAAa,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC;AACvD,CAAC;AAED,sBAAsB;AACtB,MAAM,UAAU,QAAQ;IACpB,OAAO,aAAa,CAAC,QAAQ,CAAC,CAAC;AACnC,CAAC;AAED,MAAM,UAAU,SAAS;IACrB,OAAO,aAAa,CAAC,SAAS,CAAC,CAAC;AACpC,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\nfunction testUserAgent(re: RegExp): boolean {\n return typeof window !== 'undefined' && window.navigator != null\n ? re.test(window.navigator.userAgent)\n : false;\n}\n\nfunction testPlatform(re: RegExp): boolean {\n return typeof window !== 'undefined' && window.navigator != null\n ? re.test(window.navigator.platform)\n : false;\n}\n\n/* c8 ignore next 3 */\nexport function isMac(): boolean {\n return testPlatform(/^Mac/);\n}\n\nexport function isIPhone(): boolean {\n return testPlatform(/^iPhone/);\n}\n\nexport function isIPad(): boolean {\n return (\n testPlatform(/^iPad/) ||\n // iPadOS 13 lies and says it's a Mac, but we can distinguish by detecting touch support.\n (isMac() && navigator.maxTouchPoints > 1)\n );\n}\n\nexport function isIOS(): boolean {\n return isIPhone() || isIPad();\n}\n\n/* c8 ignore next 3 */\nexport function isAppleDevice(): boolean {\n return isMac() || isIOS();\n}\n\n/* c8 ignore next 3 */\nexport function isWebKit(): boolean {\n return testUserAgent(/AppleWebKit/) && !isChrome();\n}\n\n/* c8 ignore next 3 */\nexport function isChrome(): boolean {\n return testUserAgent(/Chrome/);\n}\n\nexport function isAndroid(): boolean {\n return testUserAgent(/Android/);\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
-
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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,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"]}