* Returns a WeakRef. Uses this implementation if the real WeakRef class * is not available. * @param {Window} win * @param {Element} element * @return {WeakRef |DomBasedWeakRef}
(win, element)
| 26 | * @return {WeakRef<Element>|DomBasedWeakRef} |
| 27 | */ |
| 28 | static make(win, element) { |
| 29 | if (win.WeakRef) { |
| 30 | return new win.WeakRef(element); |
| 31 | } |
| 32 | if (!element.id) { |
| 33 | const index = (win.__AMP_WEAKREF_ID = (win.__AMP_WEAKREF_ID || 0) + 1); |
| 34 | element.id = 'weakref-id-' + index; |
| 35 | } |
| 36 | return new DomBasedWeakRef(win, element.id); |
| 37 | } |
| 38 | |
| 39 | /** @return {Element|undefined} */ |
| 40 | deref() { |
no outgoing calls
no test coverage detected