Re:Web Components could replace frontend frameworks?
by EGreg on Thursday April 11, 2019 @11:55PM
(#19641835)
Is that really valid ES6? Or are you using typescript
Re:Web Components could replace frontend frameworks?
by tobr on Friday April 12, 2019 @01:49AM
(#19642306)
> src / ui.ts
Re:Web Components could replace frontend frameworks?
by EGreg on Friday April 12, 2019 @10:34AM
(#19645127)
?
Re:Web Components could replace frontend frameworks?
by fron on Friday April 12, 2019 @12:23PM
(#19646212)
......
The .ts file extension generally means TypeScript.
Re:Web Components could replace frontend frameworks?
by austincheney on Thursday April 11, 2019 @09:46PM
(#19641189)
What about with using appendChild or insertBefore instead of innerHTML?
One of the bizarre realities with those forced to write their own "virtual DOM" library, as I have done, is to deal with all the so-called hidden state. Form field values, the user's current text selection, scrolling position. Without a virtual DOM, simply replacing existing nodes with innerHTML or replaceChild will stomp this away. I'm not of the opinion that you need a full framework to handle this state (I wrote my own 10-line helper function which works in most cases I care about [0]), but you do need something more structured than just replacing nodes wholesale.
[0] https://github.com/magcius/noclip.website/blob/master/src/ui...