4 ms·
Thank you for confirming I am not... crazy, just old then. I was staring at the code for minutes, trying to spot something unusual that I missed. So, this reall
by alentred 1y ago
Thank you for confirming I am not... crazy, just old then. I was staring at the code for minutes, trying to spot something unusual that I missed. So, this really just about the `<table>` element, or do I actually not see something?
- paperpunk 1y agoIt’s not about the table element, it’s about the API to construct and manipulate that element with a columns and rows interface which is largely superseded by general DOM manipulation.
- littlestymaar 1y agoExactly like how `getElementById` replaced the direct use of the id as a JavaScript identifier.
- xg15 1y agoI remember there being posts that explicitly discouraged using IDs directly, but I'm not sure of tge reasons anymore. Maybe browser incompatibilities or unclear scoping and confusion with other variables?
- withinboredom 1y agoIt was either Mozilla (Netscape, I think) or IE that it didn’t work on for the longest time.
- mook 1y agoI think that was a native IE API that Mozilla had to add support for, as well as document.all (Netscape used document.layers).
- chrismorgan 1y agoIt works everywhere (it’s now specified in https://html.spec.whatwg.org/multipage/nav-history-apis.html#named-access-on-the-window-object https://html.spec.whatwg.org/multipage/nav-history-apis.html...), but it’s brittle. It can break by adding colliding properties to window deliberately or by accidental global leak (… including things like setting in dev tools), by browser defining new globals, by some 'name' attribute conflict.
- xg15 1y agoIt's about the insertRow() and insertCell() methods and rows[] and cells[] fields on the table element, not the table itself.
- eterm 1y agoI figured that was the normal way to interact with tables, what would people do otherwise?
- xg15 1y agoUsing the standard DOM APIs or - if they don't care about anything - innerHTML, I suppose.
- kleiba 1y agoSorry I - also - am one of those old timers who don't understand this because the shown code is all I've ever used for creating table. So, what is this "standard DOM API" if I may ask? Could you post a code example?
- wging 1y agoYou can use document.createElement and document.appendChild to create every last <th>, <tr>, and <td> if you want. Those functions are not specific to tables, unlike the one mentioned in the blog post. They can be used to create any elements and place them in the DOM. But if you know what you are doing you can get a perfectly fine table out of that. (Not that you should.)
- xg15 1y agoYeah, that was what I was thinking of. I knew those as the essential APIs to modify the DOM without a full re-parse. And you can use them on table/th/tr/td nodes just like on any other node.
- thorum 1y ago