@lion/choice-input
Advanced tools
Comparing version 0.2.44 to 0.3.0
@@ -6,2 +6,13 @@ # Change Log | ||
# [0.3.0](https://github.com/ing-bank/lion/compare/@lion/choice-input@0.2.44...@lion/choice-input@0.3.0) (2019-11-13) | ||
### Features | ||
* remove all deprecations from lion ([66d3d39](https://github.com/ing-bank/lion/commit/66d3d390aebeaa61b6effdea7d5f7eea0e89c894)) | ||
## [0.2.44](https://github.com/ing-bank/lion/compare/@lion/choice-input@0.2.43...@lion/choice-input@0.2.44) (2019-11-12) | ||
@@ -8,0 +19,0 @@ |
{ | ||
"name": "@lion/choice-input", | ||
"version": "0.2.44", | ||
"version": "0.3.0", | ||
"description": "Base for all choise inputs like checkbox/radio", | ||
@@ -35,7 +35,7 @@ "author": "ing-bank", | ||
"dependencies": { | ||
"@lion/core": "^0.2.1", | ||
"@lion/field": "^0.3.7" | ||
"@lion/core": "^0.3.0", | ||
"@lion/field": "^0.4.0" | ||
}, | ||
"devDependencies": { | ||
"@lion/input": "^0.1.66", | ||
"@lion/input": "^0.2.0", | ||
"@open-wc/demoing-storybook": "^0.2.0", | ||
@@ -45,3 +45,3 @@ "@open-wc/testing": "^2.3.4", | ||
}, | ||
"gitHead": "64b76de801dd7f7adb47fcc45b657336a34e9bab" | ||
"gitHead": "90e6b4ef36bb5c49cfe7e4b2b8a00128334c84ab" | ||
} |
@@ -77,3 +77,2 @@ /* eslint-disable class-methods-use-this */ | ||
if (c.has('modelValue')) { | ||
this._reflectCheckedToCssClass({ modelValue: this.modelValue }); | ||
this.__syncCheckedToInputElement(); | ||
@@ -129,3 +128,2 @@ } | ||
this.addEventListener('user-input-changed', this.__toggleChecked); | ||
this._reflectCheckedToCssClass(); | ||
} | ||
@@ -151,6 +149,6 @@ | ||
__syncCheckedToInputElement() { | ||
// .inputElement might not be available yet(slot content) | ||
// ._inputNode might not be available yet(slot content) | ||
// or at all (no reliance on platform construct, in case of [role=option]) | ||
if (this.inputElement) { | ||
this.inputElement.checked = this.checked; | ||
if (this._inputNode) { | ||
this._inputNode.checked = this.checked; | ||
} | ||
@@ -223,21 +221,2 @@ } | ||
_syncValueUpwards() {} | ||
/** | ||
* @deprecated use .checked | ||
*/ | ||
get choiceChecked() { | ||
return this.checked; | ||
} | ||
/** | ||
* @deprecated use .checked | ||
*/ | ||
set choiceChecked(c) { | ||
this.checked = c; | ||
} | ||
/** @deprecated for styling purposes, use [checked] attribute */ | ||
_reflectCheckedToCssClass() { | ||
this.classList[this.checked ? 'add' : 'remove']('state-checked'); | ||
} | ||
}; |
@@ -42,3 +42,3 @@ import { expect, fixture } from '@open-wc/testing'; | ||
it('fires one "model-value-changed" event if choiceValue or choiceChecked or modelValue changed', async () => { | ||
it('fires one "model-value-changed" event if choiceValue or checked state or modelValue changed', async () => { | ||
let counter = 0; | ||
@@ -81,3 +81,3 @@ const el = await fixture(html` | ||
// Here we try to mimic user interaction by firing browser events | ||
const nativeInput = el.inputElement; | ||
const nativeInput = el._inputNode; | ||
nativeInput.dispatchEvent(new CustomEvent('input', { bubbles: true })); // fired by (at least) Chrome | ||
@@ -117,3 +117,3 @@ expect(counter).to.equal(0); | ||
await el.updateComplete; | ||
expect(el.inputElement.checked).to.be.true; | ||
expect(el._inputNode.checked).to.be.true; | ||
}); | ||
@@ -123,5 +123,5 @@ | ||
const el = await fixture(`<choice-input></choice-input>`); | ||
el.inputElement.click(); | ||
el._inputNode.click(); | ||
expect(el.checked).to.be.true; | ||
el.inputElement.click(); | ||
el._inputNode.click(); | ||
expect(el.checked).to.be.false; | ||
@@ -200,4 +200,4 @@ }); | ||
// Via user interaction | ||
el.inputElement.click(); | ||
elChecked.inputElement.click(); | ||
el._inputNode.click(); | ||
elChecked._inputNode.click(); | ||
await el.updateComplete; | ||
@@ -218,61 +218,2 @@ expect(hasAttr(el)).to.equal(true, 'user click checked'); | ||
}); | ||
it('[deprecated] synchronizes checked state to class "state-checked" for styling purposes', async () => { | ||
const hasClass = el => [].slice.call(el.classList).indexOf('state-checked') > -1; | ||
const el = await fixture(`<choice-input></choice-input>`); | ||
const elChecked = await fixture(html` | ||
<choice-input .checked=${true}> | ||
<input slot="input" /> | ||
</choice-input> | ||
`); | ||
// Initial values | ||
expect(hasClass(el)).to.equal(false, 'inital unchecked element'); | ||
expect(hasClass(elChecked)).to.equal(true, 'inital checked element'); | ||
// Programmatically via checked | ||
el.checked = true; | ||
elChecked.checked = false; | ||
await el.updateComplete; | ||
expect(hasClass(el)).to.equal(true, 'programmatically checked'); | ||
expect(hasClass(elChecked)).to.equal(false, 'programmatically unchecked'); | ||
// reset | ||
el.checked = false; | ||
elChecked.checked = true; | ||
// Via user interaction | ||
el.inputElement.click(); | ||
elChecked.inputElement.click(); | ||
await el.updateComplete; | ||
expect(hasClass(el)).to.equal(true, 'user click checked'); | ||
expect(hasClass(elChecked)).to.equal(false, 'user click unchecked'); | ||
// reset | ||
el.checked = false; | ||
elChecked.checked = true; | ||
// Programmatically via modelValue | ||
el.modelValue = { value: '', checked: true }; | ||
elChecked.modelValue = { value: '', checked: false }; | ||
await el.updateComplete; | ||
expect(hasClass(el)).to.equal(true, 'modelValue checked'); | ||
expect(hasClass(elChecked)).to.equal(false, 'modelValue unchecked'); | ||
}); | ||
it('[deprecated] uses choiceChecked to set checked state', async () => { | ||
const el = await fixture(html` | ||
<choice-input .choiceValue=${'foo'}></choice-input> | ||
`); | ||
expect(el.choiceChecked).to.be.false; | ||
el.choiceChecked = true; | ||
expect(el.checked).to.be.true; | ||
expect(el.modelValue).to.deep.equal({ | ||
checked: true, | ||
value: 'foo', | ||
}); | ||
await el.updateComplete; | ||
expect(el.inputElement.checked).to.be.true; | ||
}); | ||
}); | ||
@@ -279,0 +220,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
31450
405
+ Added@lion/core@0.3.0(transitive)
+ Added@lion/field@0.4.1(transitive)
+ Added@lion/localize@0.5.0(transitive)
+ Added@lion/validate@0.3.1(transitive)
- Removed@lion/core@0.2.1(transitive)
- Removed@lion/field@0.3.7(transitive)
- Removed@lion/localize@0.4.21(transitive)
- Removed@lion/validate@0.2.40(transitive)
Updated@lion/core@^0.3.0
Updated@lion/field@^0.4.0