Skip to content

Commit

Permalink
Merge b343343 into 61b0bf1
Browse files Browse the repository at this point in the history
  • Loading branch information
web-padawan committed Sep 12, 2018
2 parents 61b0bf1 + b343343 commit de25d65
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/vaadin-checkbox-group.html
Expand Up @@ -81,6 +81,7 @@
* -----------|-------------|------------
* `disabled` | Set when the checkbox group and its children are disabled. | :host
* `has-label` | Set when the element has a label | :host
* `has-value` | Set when the element has a value | :host
* `required` | Set when the element is required | :host
* `invalid` | Set when the element is invalid | :host
*
Expand Down Expand Up @@ -254,6 +255,13 @@
if (value.length === 0 && this._oldValue === undefined) {
return;
}

if (value.length) {
this.setAttribute('has-value', '');
} else {
this.removeAttribute('has-value');
}

this._oldValue = value;
// set a flag to avoid updating loop
this._updatingValue = true;
Expand Down
12 changes: 12 additions & 0 deletions test/vaadin-checkbox-group_test.html
Expand Up @@ -179,6 +179,18 @@
expect(vaadinCheckboxGroup.label).to.be.equal('foo');
});

it('should not have has-value attribute by default', () => {
expect(vaadinCheckboxGroup.hasAttribute('has-value')).to.be.false;
});

it('should toggle has-value attribute on value change', () => {
vaadinCheckboxGroup.value = ['2'];
expect(vaadinCheckboxGroup.hasAttribute('has-value')).to.be.true;

vaadinCheckboxGroup.value = [];
expect(vaadinCheckboxGroup.hasAttribute('has-value')).to.be.false;
});

it('should add label to checkbox group when a label is dynamically set', () => {
vaadinCheckboxGroup.label = 'foo';

Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit de25d65

Please sign in to comment.