@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/headersand 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
Headersspec. If this becomes widespread, another smoosh-gate is waiting us.Let me demonstrate with an example. Let's say we created a
Headersinstance and addedcontentTypevia the Remix helpers. If we pass it tofetchit will still work, because the consumer can still access.get('contentType'). But the issue arises if WHATWG decides to add their own.contentTypeproperty in the future. Some scenarios:array.flatwas 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