@remix-run/headers
subclassing of DOM Headers may cause future web compatibility issues (like smoosh-gate)
#10715
frontsideair
started this conversation in
General
Replies: 1 comment
-
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I've been looking at
@remix-run/headers
and this part jumped at me:It's listed as a strength, and in some ways it is, but it may cause compatibility issues in case WHATWG decides to enhance the
Headers
spec. If this becomes widespread, another smoosh-gate is waiting us.Let me demonstrate with an example. Let's say we created a
Headers
instance and addedcontentType
via the Remix helpers. If we pass it tofetch
it will still work, because the consumer can still access.get('contentType')
. But the issue arises if WHATWG decides to add their own.contentType
property in the future. Some scenarios:array.flat
was landed. In this case, we get an inferior name so the ecosystem doesn't break.I believe this is less than ideal for any possible scenario. So my suggestion would be to back away from using a subclass and make it explicit by using a method such as
remixHeaders.toHeaders()
to convert when passing to 3rd party consumers. It's not a big hassle, but save the ecosystem in the long run.Beta Was this translation helpful? Give feedback.
All reactions