-
-
Notifications
You must be signed in to change notification settings - Fork 333
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(addon/components/paper-radio-group-label): converts to a glimmer…
… component.
- Loading branch information
1 parent
94e3db0
commit e566dc8
Showing
2 changed files
with
31 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
{{! template-lint-disable no-curly-component-invocation }} | ||
{{#if (has-block)}} | ||
{{yield}} | ||
{{else}} | ||
{{@text}} | ||
{{/if}} | ||
|
||
<md-label id={{this.labelId}} {{did-insert this.didInsertNode}} ...attributes> | ||
{{#if (has-block)}} | ||
{{yield}} | ||
{{else}} | ||
{{@text}} | ||
{{/if}} | ||
</md-label> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,28 @@ | ||
/* eslint-disable ember/no-classic-components, ember/no-component-lifecycle-hooks, ember/require-tagless-components */ | ||
import Component from '@ember/component'; | ||
import Component from '@glimmer/component'; | ||
import { action } from '@ember/object'; | ||
import { guidFor } from '@ember/object/internals'; | ||
|
||
export default Component.extend({ | ||
tagName: 'md-label', | ||
export default class PaperRadioGroupLabel extends Component { | ||
/** | ||
* provides a globally unique component id for tracking bindings between aria | ||
* tags and labels. | ||
* @type {string} | ||
*/ | ||
labelId; | ||
|
||
didInsertElement() { | ||
this._super(...arguments); | ||
constructor(owner, args) { | ||
super(owner, args); | ||
|
||
if (this.setAriaLabelledby) { | ||
this.setAriaLabelledby(this.elementId); | ||
this.labelId = this.args.labelId || `${guidFor(this)}-label`; | ||
} | ||
|
||
/** | ||
* Performs any required DOM setup. | ||
* @param element | ||
*/ | ||
@action didInsertNode() { | ||
if (this.args.setAriaLabelledby) { | ||
this.args.setAriaLabelledby(this.labelId); | ||
} | ||
}, | ||
}); | ||
} | ||
} |