Twitxy Saved

stephband

@stephband

Bluesky: @stephen.band
Mastodon: @stephband@front-end.social
cruncher.ch co-founder. Front-end developer. Musician.
Lausanne stephen.band Joined December 2008
272 Following 497 Followers 3.6K Posts

Latest posts 5

stephband @stephband
All three are part of the EFTA, the single market, and have free movement. The man's absolutely right, we should be rejoining the EFTA post haste.
John Redwood Verified account @johnredwood Jul 7, 2025
Norway, Switzerland and Iceland show us how small countries not in EU can do so much better than the EU. It is nonsense to say the EU‘s size is crucial to prosperity. The single market is an unhelpful over regulated customs union.
View quoted post on X
stephband @stephband
"if you set properties in the meantime it won't trigger accessors"

I have code in all my CE constructors that deletes and then reassigns own properties to handle exactly this. I'm annoyed I have to do this.

I agree the consumer of a CE should not have to deal wi these problems.
Rich Harris Verified account @Rich_Harris Oct 2, 2024
Not really. Firstly I reject the premise that pushing the burden onto users is desirable — if a tax has to be paid, it's better for frameworks to pay it.

But beyond that, it's not just about the fact that WCs make the platform so much more complex and so much harder to learn. It directly affects users in subtle ways. For example if you want to clone some DOM to build a component you can just do `fragment.cloneNode(true)`, right? Not so fast — if the DOM contains a custom element, the clone won't be assigned the correct class until it's appended to the document, and if you set properties in the meantime it won't trigger accessors (they'll shadow the prototype instead, which is very bad news). It's a real head-scratcher of a bug.

It turns out that if you use `document.importNode(fragment, true)` instead, it works correctly. Not that you'll casually learn that while reading MDN — this is the kind of knowledge that is only acquired with a side helping of battle scars.

But there's a catch! importNode is roughly 30% slower than cloneNode in our testing. That's unacceptable overhead given that most people aren't using custom elements (and certainly not that often). So we opted to pay a different price — the compiler adds a flag to the generated code, and the flag tells the runtime which to use. That's extra code, and extra work (albeit a miniscule amount), that would be unnecessary if we didn't have to think about this nonsense.

Having the bug? Tax.
Figuring out the solution? Tax.
Implementing the fix? Tax.
Documenting the code for our future selves? Tax.
Adding regression tests? Tax.
Running those tests on every CI job?
Shipping extra code? Tax.
Doing more work in a hot code path? Tax.

And that's just one example. There are others. The bottom line is that framework authors could ship sooner, and could ship leaner and more reliable code, were it not for this ill-designed primitive with its myriad edge cases.
View quoted post on X
1 replies 1 reposts 1 likes 6.1K views View on X