Matches elements between an element and its clone and allows for their data to be cloned.
( selector: string, node: HTMLElement, clone: HTMLElement, callback: (source: T, clone: T) => void, )
| 32 | |
| 33 | /** Matches elements between an element and its clone and allows for their data to be cloned. */ |
| 34 | function transferData<T extends Element>( |
| 35 | selector: string, |
| 36 | node: HTMLElement, |
| 37 | clone: HTMLElement, |
| 38 | callback: (source: T, clone: T) => void, |
| 39 | ) { |
| 40 | const descendantElements = node.querySelectorAll<T>(selector); |
| 41 | |
| 42 | if (descendantElements.length) { |
| 43 | const cloneElements = clone.querySelectorAll<T>(selector); |
| 44 | |
| 45 | for (let i = 0; i < descendantElements.length; i++) { |
| 46 | callback(descendantElements[i], cloneElements[i]); |
| 47 | } |
| 48 | } |
| 49 | } |
| 50 | |
| 51 | // Counter for unique cloned radio button names. |
| 52 | let cloneUniqueId = 0; |
no test coverage detected
searching dependent graphs…