Live data from Hacker News

Do you know that there is an HTML tables API?

christianheilmann.com

81–90 of 206 posts

Re: Do you know that there is an HTML tables API?

#81

Earlier quoted context omitted.

Why would it matter what library you use? I'm using React, I do whenever I need to display tabular data, React or no React as no impact on when I'd use .

Just make sure to pass a subscriber to useSyncExternalStore if you decide to venture outside React and use HTMLTable.insertRow, you see react is really smart and won’t let you use this piece of outdated code without punishing you with side effects. Thanks Vercel & Meta for protecting us.

> Just make sure to pass a subscriber to useSyncExternalStore if you decide to venture outside React and use HTMLTable.insertRow, you see react is really smart and won’t let you use this piece of outdated code without punishing you with side effects.

Huh? Why'd you involve state in this or any imperative code? You render the rows/columns as you'd render any other DOM elements in React, pass in the data as props and iterate on it, create children and pass them to render.

Re: Do you know that there is an HTML tables API?

#82

Phew, this post single handedly made me feel old this morning. I started dabbling with the web just over 20 years ago but have mainly been working on the backend the past 10-15 years. I had no clue that nowadays programmers don’t know about this, so I assume it’s supplanted by modern frameworks or modern JS/CSS

I’ve been building sites since around 2000 and I’ve used HTML tables a lot (including for page layouts, remember those days?). There was a time when I thought I was fluent enough to not have to look up HTML or CSS docs for most things. But I don’t think I’ve ever actively used the DOM API that this article mentions so I learned something new today.

Re: Do you know that there is an HTML tables API?

#83

Earlier quoted context omitted.

I think it was inevitable. Most of the funded content on the web is marketing/sales-driven, and companies paying for marketing content want it to be displayed in a specific way. It’d be interesting to have a parallel DocBook web for technical content, where consumers of that content could apply their own styles to render it in a way that’s best for them.

I mean, you can just remove all the user agent styles and then is just as stylable as .

Why would marketing want to pay for the extra (and to their mind entirely pointless) work required to capture semantics?

(I’m not saying I like the world we live in, but I don’t see a likely alternative.)

Re: Do you know that there is an HTML tables API?

#84

Phew, this post single handedly made me feel old this morning. I started dabbling with the web just over 20 years ago but have mainly been working on the backend the past 10-15 years. I had no clue that nowadays programmers don’t know about this, so I assume it’s supplanted by modern frameworks or modern JS/CSS

You knew about the .insertRow() and .insertCell() methods?

Re: Do you know that there is an HTML tables API?

#85

Earlier quoted context omitted.

Most people use declarative frameworks to build tables, and you could just use `innerHTML` or `append` or any other imperative DOM API to work with tables.

Declarative frameworks build on the imperative DOM API.

And, not a single one of the declarative frameworks use the HTMLTableElement API!

Re: Do you know that there is an HTML tables API?

#86

Earlier quoted context omitted.

Most people use declarative frameworks to build tables, and you could just use `innerHTML` or `append` or any other imperative DOM API to work with tables.

Declarative frameworks build on the imperative DOM API.

They don't use .insertRow() and .insertCell(). Try searching the React codebase for those.

Re: Do you know that there is an HTML tables API?

#87
I feel like IndexedDB is becoming this abandonware as well. There are so many ways where this (IMO rather badly designed) API can be improved but the standards committee seems completely uninterested. Even things like adding BigInt as primative is unimplemented.

I fear this will be even worse now that we have the origin File System API and people can bring their own database engines (like web-assambled SQLite). But for those of us that are striving towards smaller download sizes this is a disaster.

Re: Do you know that there is an HTML tables API?

#89
post #84

Phew, this post single handedly made me feel old this morning. I started dabbling with the web just over 20 years ago but have mainly been working on the backend the past 10-15 years. I had no clue that nowadays programmers don’t know about this, so I assume it’s supplanted by modern frameworks or modern JS/CSS

You knew about the .insertRow() and .insertCell() methods?

I made my first CRUD UI that didn't do full page refreshes with those methods.

Re: Do you know that there is an HTML tables API?

#90
post #44

Earlier quoted context omitted.

It’s normal to use short names for things with short scopes.

Yes, and the reason for why that's OK is that the context is just few lines. But this is borderline due to the amount of variables. In just 4 lines you have r, row, t, ri, l, i and c. The full variables names are so short anyway that personally I'd write them out. Code does evolve and there's a risk of this suffering as a result.

That’s a fair point.
Post reply on HN