Skip to content

Commit 98fcf8c

Browse files
refactor(material): use static strings for aria roles
Closes angular#2542
1 parent da60381 commit 98fcf8c

5 files changed

Lines changed: 7 additions & 28 deletions

File tree

modules/angular2_material/src/components/checkbox/checkbox.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {NumberWrapper} from 'angular2/src/facade/lang';
1010
host: {
1111
'(keydown)': 'onKeydown($event)',
1212
'[tabindex]': 'tabindex',
13-
'[attr.role]': 'role',
13+
'[attr.role]': '"checkbox"',
1414
'[attr.aria-checked]': 'checked',
1515
'[attr.aria-disabled]': 'disabled'
1616
}
@@ -23,14 +23,10 @@ export class MdCheckbox {
2323
/** Whether this checkbox is disabled. */
2424
_disabled: boolean;
2525

26-
/** Setter for `role` attribute. */
27-
role: string;
28-
2926
/** Setter for tabindex */
3027
tabindex: number;
3128

3229
constructor(@Attribute('tabindex') tabindex: string) {
33-
this.role = 'checkbox';
3430
this.checked = false;
3531
this.tabindex = isPresent(tabindex) ? NumberWrapper.parseInt(tabindex, 10) : 0;
3632
this._disabled = false;

modules/angular2_material/src/components/grid_list/grid_list.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ export class MdGridList {
225225
'[style.left]': 'styleLeft',
226226
'[style.marginTop]': 'styleMarginTop',
227227
'[style.paddingTop]': 'stylePaddingTop',
228-
'[role]': 'role'
228+
'[role]': '"listitem"'
229229
},
230230
lifecycle: [onDestroy, onChange]
231231
})
@@ -241,15 +241,12 @@ export class MdGridTile {
241241
styleLeft: string;
242242
styleMarginTop: string;
243243
stylePaddingTop: string;
244-
role: string;
245244

246245
isRegisteredWithGridList: boolean;
247246

248247
constructor(@Parent() gridList: MdGridList) {
249248
this.gridList = gridList;
250249

251-
this.role = 'listitem';
252-
253250
// Tiles default to 1x1, but rowspan and colspan can be changed via binding.
254251
this.rowspan = 1;
255252
this.colspan = 1;

modules/angular2_material/src/components/progress-linear/progress_linear.ts

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ import {Math} from 'angular2/src/facade/math';
88
lifecycle: [onChange],
99
properties: ['value', 'bufferValue'],
1010
host: {
11-
'[attr.role]': 'role',
12-
'[attr.aria-valuemin]': 'ariaValuemin',
13-
'[attr.aria-valuemax]': 'ariaValuemax',
11+
'[attr.role]': '"progressbar"',
12+
'[attr.aria-valuemin]': '"0"',
13+
'[attr.aria-valuemax]': '"100"',
1414
'[attr.aria-valuenow]': 'value'
1515
}
1616
})
@@ -34,18 +34,10 @@ export class MdProgressLinear {
3434
/** CSS `transform` property applied to the secondary bar. */
3535
secondaryBarTransform: string;
3636

37-
role: string;
38-
ariaValuemin: string;
39-
ariaValuemax: string;
40-
4137
constructor(@Attribute('md-mode') mode: string) {
4238
this.primaryBarTransform = '';
4339
this.secondaryBarTransform = '';
4440

45-
this.role = 'progressbar';
46-
this.ariaValuemin = '0';
47-
this.ariaValuemax = '100';
48-
4941
this.mode = isPresent(mode) ? mode : Mode.DETERMINATE;
5042
}
5143

modules/angular2_material/src/components/radio/radio_button.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ var _uniqueIdCounter: number = 0;
3131
// TODO(jelbourn): Remove ^ when event retargeting is fixed.
3232
'(^keydown)': 'onKeydown($event)',
3333
'[tabindex]': 'tabindex',
34-
'[attr.role]': 'role',
34+
'[attr.role]': '"radiogroup"',
3535
'[attr.aria-disabled]': 'disabled',
3636
'[attr.aria-activedescendant]': 'activedescendant'
3737
}
@@ -61,8 +61,6 @@ export class MdRadioGroup {
6161

6262
tabindex: number;
6363

64-
role: string;
65-
6664
constructor(@Attribute('tabindex') tabindex: string, @Attribute('disabled') disabled: string,
6765
radioDispatcher: MdRadioDispatcher) {
6866
this.name_ = `md-radio-group-${_uniqueIdCounter++}`;
@@ -72,8 +70,6 @@ export class MdRadioGroup {
7270
this.selectedRadioId = '';
7371
this.disabled_ = false;
7472

75-
this.role = 'radiogroup';
76-
7773
// The simple presence of the `disabled` attribute dictates disabled state.
7874
this.disabled = isPresent(disabled);
7975

modules/angular2_material/src/components/switcher/switch.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {NumberWrapper} from 'angular2/src/facade/lang';
1313
'(keydown)': 'onKeydown($event)',
1414
'[attr.aria-checked]': 'checked',
1515
'[attr.aria-disabled]': 'disabled_',
16-
'[attr.role]': 'role'
16+
'[attr.role]': '"checkbox"'
1717
}
1818
})
1919
@View({templateUrl: 'angular2_material/src/components/switcher/switch.html', directives: []})
@@ -25,10 +25,8 @@ export class MdSwitch {
2525
disabled_: boolean;
2626

2727
tabindex: number;
28-
role: string;
2928

3029
constructor(@Attribute('tabindex') tabindex: string) {
31-
this.role = 'checkbox';
3230
this.checked = false;
3331
this.tabindex = isPresent(tabindex) ? NumberWrapper.parseInt(tabindex, 10) : 0;
3432
}

0 commit comments

Comments
 (0)