Skip to content

Commit 7b52c45

Browse files
asynclizcopybara-github
authored andcommitted
fix: remove @AriaProperty decorator
PiperOrigin-RevId: 526750432
1 parent 07207b4 commit 7b52c45

File tree

22 files changed

+194
-492
lines changed

22 files changed

+194
-492
lines changed

checkbox/lib/checkbox.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,23 @@ import {property, query, queryAsync, state} from 'lit/decorators.js';
1212
import {classMap} from 'lit/directives/class-map.js';
1313
import {when} from 'lit/directives/when.js';
1414

15+
import {requestUpdateOnAriaChange} from '../../aria/delegate.js';
1516
import {dispatchActivationClick, isActivationClick, redispatchEvent} from '../../controller/events.js';
1617
import {FormController, getFormValue} from '../../controller/form-controller.js';
1718
import {stringConverter} from '../../controller/string-converter.js';
18-
import {ariaProperty} from '../../decorators/aria-property.js';
1919
import {pointerPress, shouldShowStrongFocus} from '../../focus/strong-focus.js';
2020
import {ripple} from '../../ripple/directive.js';
2121
import {MdRipple} from '../../ripple/ripple.js';
22+
import {ARIAMixinStrict} from '../../types/aria.js';
2223

2324
/**
2425
* A checkbox component.
2526
*/
2627
export class Checkbox extends LitElement {
28+
static {
29+
requestUpdateOnAriaChange(this);
30+
}
31+
2732
/**
2833
* @nocollapse
2934
*/
@@ -70,10 +75,6 @@ export class Checkbox extends LitElement {
7075
return this.closest('form');
7176
}
7277

73-
@ariaProperty // tslint:disable-line:no-new-decorators
74-
@property({attribute: 'data-aria-label', noAccessor: true})
75-
override ariaLabel!: string;
76-
7778
@state() private prevChecked = false;
7879
@state() private prevDisabled = false;
7980
@state() private prevIndeterminate = false;
@@ -135,6 +136,8 @@ export class Checkbox extends LitElement {
135136
'prev-disabled': this.prevDisabled,
136137
});
137138

139+
// Needed for closure conformance
140+
const {ariaLabel} = this as ARIAMixinStrict;
138141
return html`
139142
<div class="container ${containerClasses}">
140143
<div class="outline"></div>
@@ -148,7 +151,7 @@ export class Checkbox extends LitElement {
148151
</div>
149152
<input type="checkbox"
150153
aria-checked=${isIndeterminate ? 'mixed' : nothing}
151-
aria-label=${this.ariaLabel || nothing}
154+
aria-label=${ariaLabel || nothing}
152155
?disabled=${this.disabled}
153156
.indeterminate=${this.indeterminate}
154157
.checked=${this.checked}

circularprogress/lib/circular-progress.ts

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,17 @@ import {html, LitElement, nothing, TemplateResult} from 'lit';
88
import {property} from 'lit/decorators.js';
99
import {classMap} from 'lit/directives/class-map.js';
1010

11-
import {ariaProperty} from '../../decorators/aria-property.js';
11+
import {requestUpdateOnAriaChange} from '../../aria/delegate.js';
12+
import {ARIAMixinStrict} from '../../types/aria.js';
1213

1314
/**
1415
* Circular Progress component.
1516
*/
1617
export class CircularProgress extends LitElement {
18+
static {
19+
requestUpdateOnAriaChange(this);
20+
}
21+
1722
/**
1823
* Progress to display, a fraction between 0 and 1.
1924
*/
@@ -32,22 +37,19 @@ export class CircularProgress extends LitElement {
3237
*/
3338
@property({type: Boolean, attribute: 'four-color'}) fourColor = false;
3439

35-
@property({attribute: 'data-aria-label', noAccessor: true})
36-
// tslint:disable-next-line:no-new-decorators
37-
@ariaProperty
38-
override ariaLabel!: string;
39-
4040
protected override render(): TemplateResult {
4141
const classes = {
4242
'indeterminate': this.indeterminate,
4343
'four-color': this.fourColor
4444
};
4545

46+
// Needed for closure conformance
47+
const {ariaLabel} = this as ARIAMixinStrict;
4648
return html`
4749
<div
4850
class="circular-progress ${classMap(classes)}"
4951
role="progressbar"
50-
aria-label="${this.ariaLabel || nothing}"
52+
aria-label="${ariaLabel || nothing}"
5153
aria-valuemin="0"
5254
aria-valuemax="1"
5355
aria-valuenow="${this.indeterminate ? nothing : this.progress}">
@@ -58,7 +60,7 @@ export class CircularProgress extends LitElement {
5860
<slot></slot>`;
5961
}
6062

61-
// Determinate mode is rendered with an svg so the progress arc can be
63+
// Determinate mode is rendered with an svg so the progress arc can be
6264
// easily animated via stroke-dashoffset.
6365
protected renderDeterminateContainer() {
6466
const dashOffset = (1 - this.progress) * 100;
@@ -72,10 +74,10 @@ export class CircularProgress extends LitElement {
7274
</svg>`;
7375
}
7476

75-
// Indeterminate mode rendered with 2 bordered-divs. The borders are
77+
// Indeterminate mode rendered with 2 bordered-divs. The borders are
7678
// clipped into half circles by their containers. The divs are then carefully
7779
// animated to produce changes to the spinner arc size.
78-
// This approach has 4.5x the FPS of rendering via svg on Chrome 111.
80+
// This approach has 4.5x the FPS of rendering via svg on Chrome 111.
7981
// See https://lit.dev/playground/#gist=febb773565272f75408ab06a0eb49746.
8082
protected renderIndeterminateContainer() {
8183
return html`
@@ -88,4 +90,4 @@ export class CircularProgress extends LitElement {
8890
</div>
8991
</div>`;
9092
}
91-
}
93+
}

decorators/aria-property.ts

Lines changed: 0 additions & 105 deletions
This file was deleted.

decorators/test/aria-property_test.ts

Lines changed: 0 additions & 103 deletions
This file was deleted.

fab/lib/shared.ts

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44
* SPDX-License-Identifier: Apache-2.0
55
*/
66

7-
// This is required for @ariaProperty
8-
// tslint:disable:no-new-decorators
9-
107
import '../../elevation/elevation.js';
118
import '../../focus/focus-ring.js';
129
import '../../ripple/ripple.js';
@@ -16,10 +13,11 @@ import {property, queryAsync, state} from 'lit/decorators.js';
1613
import {ClassInfo, classMap} from 'lit/directives/class-map.js';
1714
import {when} from 'lit/directives/when.js';
1815

19-
import {ariaProperty} from '../../decorators/aria-property.js';
16+
import {requestUpdateOnAriaChange} from '../../aria/delegate.js';
2017
import {pointerPress, shouldShowStrongFocus} from '../../focus/strong-focus.js';
2118
import {ripple} from '../../ripple/directive.js';
2219
import {MdRipple} from '../../ripple/ripple.js';
20+
import {ARIAMixinStrict} from '../../types/aria.js';
2321

2422
/**
2523
* Sizes variants available to non-extended FABs.
@@ -28,14 +26,15 @@ export type FabSize = 'medium'|'small'|'large';
2826

2927
// tslint:disable-next-line:enforce-comments-on-exported-symbols
3028
export abstract class SharedFab extends LitElement {
29+
static {
30+
requestUpdateOnAriaChange(this);
31+
}
32+
3133
static override shadowRootOptions: ShadowRootInit = {
3234
mode: 'open' as const,
3335
delegatesFocus: true,
3436
};
3537

36-
@property({attribute: 'data-aria-label', noAccessor: true})
37-
@ariaProperty
38-
override ariaLabel!: string;
3938
/**
4039
* The size of the FAB.
4140
*
@@ -71,13 +70,15 @@ export abstract class SharedFab extends LitElement {
7170
};
7271

7372
protected override render(): TemplateResult {
73+
// Needed for closure conformance
74+
const {ariaLabel} = this as ARIAMixinStrict;
7475
return html`
7576
<button
7677
class="fab ${classMap(this.getRenderClasses())}"
77-
aria-label="${this.ariaLabel || nothing}"
78-
@focus="${this.handleFocus}"
79-
@blur="${this.handleBlur}"
80-
@pointerdown="${this.handlePointerDown}"
78+
aria-label=${ariaLabel || nothing}
79+
@focus=${this.handleFocus}
80+
@blur=${this.handleBlur}
81+
@pointerdown=${this.handlePointerDown}
8182
${ripple(this.getRipple)}>
8283
${this.renderElevation()}
8384
${this.renderFocusRing()}

0 commit comments

Comments
 (0)