@spectrum-web-components/switch 0.39.4 → 0.40.0

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/switch",
3
- "version": "0.39.4",
3
+ "version": "0.40.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -58,8 +58,8 @@
58
58
  "lit-html"
59
59
  ],
60
60
  "dependencies": {
61
- "@spectrum-web-components/base": "^0.39.4",
62
- "@spectrum-web-components/checkbox": "^0.39.4"
61
+ "@spectrum-web-components/base": "^0.40.0",
62
+ "@spectrum-web-components/checkbox": "^0.40.0"
63
63
  },
64
64
  "devDependencies": {
65
65
  "@spectrum-css/switch": "^4.0.7"
@@ -70,5 +70,5 @@
70
70
  "./sp-*.js",
71
71
  "./**/*.dev.js"
72
72
  ],
73
- "gitHead": "f745c90e8e9ea85ff10be025e058b14cc925ec9f"
73
+ "gitHead": "24d5569a839da94892ecfd125428779587ffb1f5"
74
74
  }
@@ -36,6 +36,15 @@ describe("Switch", () => {
36
36
  const inputEl = inputForSwitch(el);
37
37
  expect(labelEl.getAttribute("for")).to.equal(inputEl.id);
38
38
  });
39
+ it("has name attribute", async () => {
40
+ const el = await fixture(
41
+ html`
42
+ <sp-switch>Not Checked</sp-switch>
43
+ `
44
+ );
45
+ await elementUpdated(el);
46
+ await expect(el.hasAttribute("name"));
47
+ });
39
48
  it("loads `checked` switch accessibly", async () => {
40
49
  const el = await fixture(
41
50
  html`
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["switch.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 '@spectrum-web-components/switch/sp-switch.js';\nimport { Switch } from '@spectrum-web-components/switch';\nimport { elementUpdated, expect, fixture, html } from '@open-wc/testing';\nimport { testForLitDevWarnings } from '../../../test/testing-helpers.js';\n\nfunction inputForSwitch(checkbox: Switch): HTMLInputElement {\n if (!checkbox.shadowRoot) throw new Error('No shadowRoot');\n return checkbox.shadowRoot.querySelector('#input') as HTMLInputElement;\n}\n\nfunction labelForSwitch(checkbox: Switch): HTMLLabelElement {\n if (!checkbox.shadowRoot) throw new Error('No shadowRoot');\n const labelEl = checkbox.shadowRoot.querySelector('label');\n if (!labelEl) {\n throw new Error('Failed to find label in shadowRoot');\n }\n return labelEl;\n}\n\ndescribe('Switch', () => {\n testForLitDevWarnings(\n async () =>\n await fixture<Switch>(\n html`\n <sp-switch>Not Checked</sp-switch>\n `\n )\n );\n it('loads default switch accessibly', async () => {\n const el = await fixture<Switch>(\n html`\n <sp-switch>Not Checked</sp-switch>\n `\n );\n\n await elementUpdated(el);\n\n await expect(el).to.be.accessible();\n\n const labelEl = labelForSwitch(el);\n const inputEl = inputForSwitch(el);\n\n expect(labelEl.getAttribute('for')).to.equal(inputEl.id);\n });\n it('loads `checked` switch accessibly', async () => {\n const el = await fixture<Switch>(\n html`\n <sp-switch checked>Checked</sp-switch>\n `\n );\n\n await elementUpdated(el);\n\n await expect(el).to.be.accessible();\n\n const labelEl = labelForSwitch(el);\n const inputEl = inputForSwitch(el);\n\n expect(labelEl.getAttribute('for')).to.equal(inputEl.id);\n });\n\n it('maintains its value when [readonly]', async () => {\n const el = await fixture<Switch>(html`\n <sp-switch checked readonly>Component</sp-switch>\n `);\n expect(el.checked).to.be.true;\n\n el.focusElement.click();\n await elementUpdated(el);\n\n expect(el.checked).to.be.true;\n });\n});\n"],
5
- "mappings": ";AAYA,OAAO;AA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aAAa,MAAM;AACtB,UAAM,eAAe,EAAE;AAEvB,WAAO,GAAG,OAAO,EAAE,GAAG,GAAG;AAAA,EAC7B,CAAC;AACL,CAAC;",
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 '@spectrum-web-components/switch/sp-switch.js';\nimport { Switch } from '@spectrum-web-components/switch';\nimport { elementUpdated, expect, fixture, html } from '@open-wc/testing';\nimport { testForLitDevWarnings } from '../../../test/testing-helpers.js';\n\nfunction inputForSwitch(checkbox: Switch): HTMLInputElement {\n if (!checkbox.shadowRoot) throw new Error('No shadowRoot');\n return checkbox.shadowRoot.querySelector('#input') as HTMLInputElement;\n}\n\nfunction labelForSwitch(checkbox: Switch): HTMLLabelElement {\n if (!checkbox.shadowRoot) throw new Error('No shadowRoot');\n const labelEl = checkbox.shadowRoot.querySelector('label');\n if (!labelEl) {\n throw new Error('Failed to find label in shadowRoot');\n }\n return labelEl;\n}\n\ndescribe('Switch', () => {\n testForLitDevWarnings(\n async () =>\n await fixture<Switch>(\n html`\n <sp-switch>Not Checked</sp-switch>\n `\n )\n );\n it('loads default switch accessibly', async () => {\n const el = await fixture<Switch>(\n html`\n <sp-switch>Not Checked</sp-switch>\n `\n );\n\n await elementUpdated(el);\n\n await expect(el).to.be.accessible();\n\n const labelEl = labelForSwitch(el);\n const inputEl = inputForSwitch(el);\n\n expect(labelEl.getAttribute('for')).to.equal(inputEl.id);\n });\n it('has name attribute', async () => {\n const el = await fixture<Switch>(\n html`\n <sp-switch>Not Checked</sp-switch>\n `\n );\n\n await elementUpdated(el);\n\n await expect(el.hasAttribute('name'));\n });\n it('loads `checked` switch accessibly', async () => {\n const el = await fixture<Switch>(\n html`\n <sp-switch checked>Checked</sp-switch>\n `\n );\n\n await elementUpdated(el);\n\n await expect(el).to.be.accessible();\n\n const labelEl = labelForSwitch(el);\n const inputEl = inputForSwitch(el);\n\n expect(labelEl.getAttribute('for')).to.equal(inputEl.id);\n });\n\n it('maintains its value when [readonly]', async () => {\n const el = await fixture<Switch>(html`\n <sp-switch checked readonly>Component</sp-switch>\n `);\n expect(el.checked).to.be.true;\n\n el.focusElement.click();\n await elementUpdated(el);\n\n expect(el.checked).to.be.true;\n });\n});\n"],
5
+ "mappings": ";AAYA,OAAO;AAEP,SAAS,gBAAgB,QAAQ,SAAS,YAAY;AACtD,SAAS,6BAA6B;AAEtC,SAAS,eAAe,UAAoC;AACxD,MAAI,CAAC,SAAS;AAAY,UAAM,IAAI,MAAM,eAAe;AACzD,SAAO,SAAS,WAAW,cAAc,QAAQ;AACrD;AAEA,SAAS,eAAe,UAAoC;AACxD,MAAI,CAAC,SAAS;AAAY,UAAM,IAAI,MAAM,eAAe;AACzD,QAAM,UAAU,SAAS,WAAW,cAAc,OAAO;AACzD,MAAI,CAAC,SAAS;AACV,UAAM,IAAI,MAAM,oCAAoC;AAAA,EACxD;AACA,SAAO;AACX;AAEA,SAAS,UAAU,MAAM;AACrB;AAAA,IACI,YACI,MAAM;AAAA,MACF;AAAA;AAAA;AAAA,IAGJ;AAAA,EACR;AACA,KAAG,mCAAmC,YAAY;AAC9C,UAAM,KAAK,MAAM;AAAA,MACb;AAAA;AAAA;AAAA,IAGJ;AAEA,UAAM,eAAe,EAAE;AAEvB,UAAM,OAAO,EAAE,EAAE,GAAG,GAAG,WAAW;AAElC,UAAM,UAAU,eAAe,EAAE;AACjC,UAAM,UAAU,eAAe,EAAE;AAEjC,WAAO,QAAQ,aAAa,KAAK,CAAC,EAAE,GAAG,MAAM,QAAQ,EAAE;AAAA,EAC3D,CAAC;AACD,KAAG,sBAAs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