Re:Cash: An absurdly small jQuery alternative for modern bro...
by kccqzy on Saturday November 02, 2024 @06:21PM
(#42029627)
The MDN page you linked to includes a nice selection logger example. It just doesn't work on my Safari (iOS).
Re:Cash: An absurdly small jQuery alternative for modern bro...
by chrismorgan on Saturday November 02, 2024 @10:48PM
(#42030858)
And does an equivalent in React work? Because I don't believe React does any of the papering-over you describe. My understanding (as a non-user) is that React does, logically, essentially nothing special around event handling.
Re:Cash: An absurdly small jQuery alternative for modern bro...
by kccqzy on Saturday November 02, 2024 @11:23PM
(#42030954)
I don't remember off the top of my head whether this specific example works in React as I'm not next to a computer. But I remember reading React source code and finding a whole lot of code to handle the select event. (Just found it by doing a GitHub code search on my phone https://github.com/facebook/react/blob/7c8e5e7ab8bb63de91163...)
In general React has its own event handling code. For one in React the user doesn't even deal with the browser native DOM events but React synthetic events. React also readily creates brand new synthetic events from other browser events. React also sometimes gives different names or behaviors to browser events; the most famous example is that the React onChange event is roughly equivalent to the browser onInput event, but absolutely different from the browser onChange event.
Re:Cash: An absurdly small jQuery alternative for modern bro...
by chrismorgan on Saturday November 02, 2024 @11:48PM
(#42031027)
Good to know, thanks. I knew it made synthetic events, but thought it was all still 1:1. I see I was completely wrong. I gotta say, yuck. Don't like it, wish they'd taken a more polyfill-like approach.
Re:Cash: An absurdly small jQuery alternative for modern bro...
by Izkata on Sunday November 03, 2024 @01:37AM
(#42031489)
IIRC they do that to deal with browser differences and be consistent with things like event bubbling. Probably other benefits as well but that's the one I'm fairly sure I remember from years ago.
Re:Cash: An absurdly small jQuery alternative for modern bro...
by fiddlerwoaroof on Saturday November 02, 2024 @11:25PM
(#42030959)
There are a couple of edge cases I forget at the moment where react event handlers intentionally behave differently from the DOM handlers with the same name.
https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputEl...