4 ms·
What does storing the state as a WeakMap do here?
by peanut_worm 5y ago
What does storing the state as a WeakMap do here?
- Ndymium 5y agoIf the custom DOM element is deleted, then its entry in the map will also be deleted. Otherwise it would hang around in the Map forever (unless manually deleted in a lifecycle callback).
- atirip 5y agoI initially just mimicked the React version into Vanilla, so this was a show-off how to do that somewhat exactly the same way. But in this particular case it serves no meaning, we can always read 'checked' from DOM.