(ref, value, vnode)
| 615 | * @param {VNode} vnode |
| 616 | */ |
| 617 | export function applyRef(ref, value, vnode) { |
| 618 | try { |
| 619 | if (typeof ref == 'function') { |
| 620 | let hasRefUnmount = typeof ref._unmount == 'function'; |
| 621 | if (hasRefUnmount) { |
| 622 | // @ts-ignore TS doesn't like moving narrowing checks into variables |
| 623 | ref._unmount(); |
| 624 | } |
| 625 | |
| 626 | if (!hasRefUnmount || value != NULL) { |
| 627 | // Store the cleanup function on the function |
| 628 | // instance object itself to avoid shape |
| 629 | // transitioning vnode |
| 630 | ref._unmount = ref(value); |
| 631 | } |
| 632 | } else ref.current = value; |
| 633 | } catch (e) { |
| 634 | options._catchError(e, vnode); |
| 635 | } |
| 636 | } |
| 637 | |
| 638 | /** |
| 639 | * Unmount a virtual node from the tree and apply DOM changes |
no test coverage detected
searching dependent graphs…