[HN Gopher] Why I Like Using Maps (and WeakMaps) for Handling DO...
       ___________________________________________________________________
        
       Why I Like Using Maps (and WeakMaps) for Handling DOM Nodes
        
       Author : joelkesler
       Score  : 40 points
       Date   : 2023-05-02 22:42 UTC (3 days ago)
        
 (HTM) web link (www.macarthur.me)
 (TXT) w3m dump (www.macarthur.me)
        
       | geuis wrote:
       | This might be one of the more interesting articles I've read in a
       | few years that deal with low level direct DOM manipulation vs
       | "yet another thing about React".
        
         | thex10 wrote:
         | Yeah, I've too noticed how hard it is to find any web
         | development guidance involving direct DOM manipulation now!
         | 
         | I was recently refactoring some code and wondering whether to
         | use a (JS) class... The search results were mostly about React
         | Class Components. And I was contemplating building a reusable
         | component... results from the past decade were split between
         | React Components and Web components. (In retrospect I should've
         | tried DDG or something not connected to my search history lol).
         | 
         | Anyway where are the vanilla JS/TS DOM manipulators blogging
         | these days? I guess here is one, thankful for the post :)
        
       | globalise83 wrote:
       | Nice! I have used Maps often for storing arbitrary key-value
       | pairs, but until 5 minutes ago I didn't know you could use object
       | references as keys. So this was a very good use of 5 mins.
        
       | akira2501 wrote:
       | Why not just use the 'dataset' property of the element itself?
       | Then you can use querySelectorAll to find your selected rows
       | automatically:                   node.querySelectorAll('tr[data-
       | selected="true"]');
       | 
       | In other words.. "use the DOM to handle the DOM."
        
       ___________________________________________________________________
       (page generated 2023-05-05 23:00 UTC)