Skip to content

Commit

Permalink
refactor: change private method name and body
Browse files Browse the repository at this point in the history
  • Loading branch information
DiegoCardoso committed May 27, 2020
1 parent 1bfc116 commit 6671a1d
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions src/vaadin-radio-group.html
Expand Up @@ -98,7 +98,7 @@
* `has-label` | Set when the element has a label | :host
* `has-value` | Set when the element has a value | :host
* `has-helper` | Set when the element has helper text or slot | :host
* `has-error-message` | Set when the element has an error message | :host
* `has-error-message` | Set when the element has an error message, regardless if the field is valid or not | :host
* `focused` | Set when the element contains focus | :host
*
* See [ThemableMixin – how to apply styles for shadow parts](https://github.com/vaadin/vaadin-themable-mixin/wiki)
Expand Down Expand Up @@ -236,7 +236,7 @@
}
});

this._onHelperSlotChange();
this._setOrToggleHasHelperAttribute();
});

if (this._radioButtons.length) {
Expand Down Expand Up @@ -475,18 +475,14 @@
}

/** @private */
_onHelperSlotChange() {
_setOrToggleHasHelperAttribute() {
const slottedNodes = this.shadowRoot.querySelector(`[name="helper"]`).assignedNodes();
// Only has slotted helper if not a text node
// Text nodes are added by the helperText prop and not the helper slot
// The filter is added due to shady DOM triggering this slotchange event on helperText prop change
this._hasSlottedHelper = slottedNodes.filter(node => node.nodeType !== 3).length;

if (this._hasSlottedHelper) {
this.setAttribute('has-helper', 'slotted');
} else if (this.helperText === '' || this.helperText === null) {
this.removeAttribute('has-helper');
}
this._setOrToggleAttribute('has-helper', this._hasSlottedHelper ? 'slotted' : this.helperText === 0 || !!this.helperText);
}

_getActiveErrorId(invalid, errorMessage, errorId) {
Expand Down

0 comments on commit 6671a1d

Please sign in to comment.