File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -49,7 +49,8 @@ export class CdkCopyToClipboard implements OnDestroy {
4949
5050 /**
5151 * How many times to attempt to copy the text. This may be necessary for longer text, because
52- * the browser needs time to fill an intermediate textarea element and copy the content.
52+ * the browser needs time to fill an intermediate textarea element and copy the content. Attempts
53+ * are cappted out at 50.
5354 */
5455 @Input ( 'cdkCopyToClipboardAttempts' ) attempts : number = 1 ;
5556
@@ -78,6 +79,9 @@ export class CdkCopyToClipboard implements OnDestroy {
7879
7980 /** Copies the current text to the clipboard. */
8081 copy ( attempts : number = this . attempts ) : void {
82+ // Avoid triggering an infinite loop if a large number of attempts is passed in.
83+ attempts = Math . min ( attempts , 50 ) ;
84+
8185 if ( attempts > 1 ) {
8286 let remainingAttempts = attempts ;
8387 const pending = this . _clipboard . beginCopy ( this . text ) ;
You can’t perform that action at this time.
0 commit comments