Transfers the data of one input element to another.
(
source: Element & {value: string},
clone: Element & {value: string; name: string; type: string},
)
| 53 | |
| 54 | /** Transfers the data of one input element to another. */ |
| 55 | function transferInputData( |
| 56 | source: Element & {value: string}, |
| 57 | clone: Element & {value: string; name: string; type: string}, |
| 58 | ) { |
| 59 | // Browsers throw an error when assigning the value of a file input programmatically. |
| 60 | if (clone.type !== 'file') { |
| 61 | clone.value = source.value; |
| 62 | } |
| 63 | |
| 64 | // Radio button `name` attributes must be unique for radio button groups |
| 65 | // otherwise original radio buttons can lose their checked state |
| 66 | // once the clone is inserted in the DOM. |
| 67 | if (clone.type === 'radio' && clone.name) { |
| 68 | clone.name = `mat-clone-${clone.name}-${cloneUniqueId++}`; |
| 69 | } |
| 70 | } |
| 71 | |
| 72 | /** Transfers the data of one canvas element to another. */ |
| 73 | function transferCanvasData(source: HTMLCanvasElement, clone: HTMLCanvasElement) { |