Skip to content

Commit 3d141ea

Browse files
authored
refactor(clipboard): remove deprecated APIs for version 10 (#19362)
Changes the APIs that have been marked as deprecated for v10. BREAKING CHANGES: * The `copied` event from `cdkCopyToClipboard` has been renamed to `cdkCopyToClipboardCopied`. * The `_ngZone` parameter in the `CdkCopyToClipboard` constructor is now required.
1 parent df795a8 commit 3d141ea

File tree

3 files changed

+17
-24
lines changed

3 files changed

+17
-24
lines changed

src/cdk/clipboard/copy-to-clipboard.ts

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,6 @@ export class CdkCopyToClipboard implements OnDestroy {
5656
*/
5757
@Output('cdkCopyToClipboardCopied') copied = new EventEmitter<boolean>();
5858

59-
/**
60-
* Emits when some text is copied to the clipboard. The
61-
* emitted value indicates whether copying was successful.
62-
* @deprecated Use `cdkCopyToClipboardCopied` instead.
63-
* @breaking-change 10.0.0
64-
*/
65-
@Output('copied') _deprecatedCopied = this.copied;
66-
6759
/** Copies that are currently being attempted. */
6860
private _pending = new Set<PendingCopy>();
6961

@@ -75,11 +67,7 @@ export class CdkCopyToClipboard implements OnDestroy {
7567

7668
constructor(
7769
private _clipboard: Clipboard,
78-
/**
79-
* @deprecated _ngZone parameter to become required.
80-
* @breaking-change 10.0.0
81-
*/
82-
private _ngZone?: NgZone,
70+
private _ngZone: NgZone,
8371
@Optional() @Inject(CKD_COPY_TO_CLIPBOARD_CONFIG) config?: CdkCopyToClipboardConfig) {
8472

8573
if (config && config.attempts != null) {
@@ -97,13 +85,8 @@ export class CdkCopyToClipboard implements OnDestroy {
9785
const attempt = () => {
9886
const successful = pending.copy();
9987
if (!successful && --remainingAttempts && !this._destroyed) {
100-
// @breaking-change 10.0.0 Remove null check for `_ngZone`.
101-
if (this._ngZone) {
102-
this._currentTimeout = this._ngZone.runOutsideAngular(() => setTimeout(attempt, 1));
103-
} else {
104-
// We use 1 for the timeout since it's more predictable when flushing in unit tests.
105-
this._currentTimeout = setTimeout(attempt, 1);
106-
}
88+
// We use 1 for the timeout since it's more predictable when flushing in unit tests.
89+
this._currentTimeout = this._ngZone.runOutsideAngular(() => setTimeout(attempt, 1));
10790
} else {
10891
this._currentTimeout = null;
10992
this._pending.delete(pending);

src/cdk/schematics/ng-update/data/output-names.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,17 @@ export interface OutputNameUpgradeData {
2424
}
2525

2626
export const outputNames: VersionChanges<OutputNameUpgradeData> = {
27+
[TargetVersion.V10]: [
28+
{
29+
pr: 'https://github.com/angular/components/pull/19362',
30+
changes: [{
31+
replace: 'copied',
32+
replaceWith: 'cdkCopyToClipboardCopied',
33+
whitelist: {
34+
attributes: ['cdkCopyToClipboard']
35+
}
36+
}]
37+
}
38+
],
2739
[TargetVersion.V6]: [],
2840
};

tools/public_api_guard/cdk/clipboard.d.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
export declare class CdkCopyToClipboard implements OnDestroy {
2-
_deprecatedCopied: EventEmitter<boolean>;
32
attempts: number;
43
copied: EventEmitter<boolean>;
54
text: string;
6-
constructor(_clipboard: Clipboard,
7-
_ngZone?: NgZone | undefined, config?: CdkCopyToClipboardConfig);
5+
constructor(_clipboard: Clipboard, _ngZone: NgZone, config?: CdkCopyToClipboardConfig);
86
copy(attempts?: number): void;
97
ngOnDestroy(): void;
10-
static ɵdir: i0.ɵɵDirectiveDefWithMeta<CdkCopyToClipboard, "[cdkCopyToClipboard]", never, { "text": "cdkCopyToClipboard"; "attempts": "cdkCopyToClipboardAttempts"; }, { "copied": "cdkCopyToClipboardCopied"; "_deprecatedCopied": "copied"; }, never>;
8+
static ɵdir: i0.ɵɵDirectiveDefWithMeta<CdkCopyToClipboard, "[cdkCopyToClipboard]", never, { "text": "cdkCopyToClipboard"; "attempts": "cdkCopyToClipboardAttempts"; }, { "copied": "cdkCopyToClipboardCopied"; }, never>;
119
static ɵfac: i0.ɵɵFactoryDef<CdkCopyToClipboard, [null, null, { optional: true; }]>;
1210
}
1311

0 commit comments

Comments
 (0)