-
Notifications
You must be signed in to change notification settings - Fork 282
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Strive for symmetrical API to browsers FormData. #124
Comments
👍 Looks like a plan |
After realizing that the |
@alexindigo What is your opinion on making form-data expose the global FormData? This would likely be a 2.x thing, however I think it would position the library as more of a "browserfill", similar to node-fetch which exposes global fetch. Unrelated: |
Like And great job on bringing libraries closer together (but not too close to keep it PG) :) Thanks. |
To keep compatibility with older versions we could still expose FormData via module.exports but also expose it as a global. |
Main purpose of this module is to allow form submission from the server-side. Exposing global variables by default would be very unexpected by majority of consumers. But I see your desire for isomorphic all the things!™ :) How about if we'd have another module, that would announce it's global nature more explicitly. For example: package.json:
index.js:
|
@alexindigo I think that is a great idea since it wouldn't require a major release. The only concern is if users might find it confusing to have two packages - not sure if thats an issue. |
New module would behave exactly as the original one plus global export which is specified in the name. Only confusion I can see could happen with versions, for that case owner of the new module, could stick to strict version dependency and update the package along with Like:
|
@alexindigo I think a As for names, after thinking about it a bit I quite like Either way I think this would be a great addition. |
@alexindigo What is your opinion on supporting passing a form element to the FormData constructor? It may be a bit crazy - (Currently I have never needed this) - however after thinking about it, one potential use case would be supporting something like JS-DOM. This could make testing form submission with JSDOM a bit easier. We could defer the actual form parsing logic to a dependency, keeping changes to this lib to a minimum. Again this may not be particularly useful but I would like to know what others think. |
Btw, I found interesting thing:
|
As for form parsing, I think it should be different module as well. Maybe we'd expose more guts from FormData for other module to be able to use it in more efficient way. Btw, we're creating new org for this project, so this new module and that isomorphic shim you mentioned could be under same umbrella if you like. |
Just a question: why is this module supposed to be a polyfill for the browser's FormData class? That scenario would be possible to use only via Browserify, Webpack or something like that, and then again I don't see the point. I would rather like to see the actual multipart body generation cleaned up and extracted into a separate module along with all of the stream helper functions around it. If that layer is made good enough, then it will be much easier to extend it for other multipart types, while keeping the existing fixes. From the request's perspective for example we don't even need a submit method. |
That's the plan, to make it library for libraries. We will split it. And yes Streams need more love. :) First step would be test coverage, though. |
Thanks for the opinion btw. |
@alexindigo not a problem. I'm also not against the polyfill, I just want the generation logic as a separate module :) Here are a few |
Yep, I do like leveldb approach. And thanks a lot for the tests. We'll incorporate them into new test suite. |
I think it would be awesome to have a library more focused on multipart generation without things like "submit". It would allow for us to more easily do a polyfill in the future. Having said that this would involve turning the library into more of a utility with less features and with so many dependants I'm sure lots would break. @alexindigo what are your thoughts on something like " form-data-core" (please better name) along side "form-data-polyfill" and "isomorphic-formdata"? 4 repos in total. |
@DylanPiercey I thought you'd like the idea of For now Grandiose Plan looks like following:
And the actual libraries, we need something that does streaming multipart for sure. Then bunch of plugins to determine content length and type. And seems like we're about to have multiple aggregators like the one to be library for libraries, another one as browser polyfil and another one as server-side-only consumer friendly. And if we can make them not to wrap one another, but assemble same components in different manner it will be uber awesome. But it's my pipe dream, let's see how it goes. :) |
Also like the idea of submit-less formData
Just want to propose to you this polyfill https://github.com/jimmywarting/FormData/blob/master/FormData.js (it's built for the browser...) but you are free to copy as much code as you like from my polyfill if it's to any help |
Any traction on this? A unified API would be amazing. |
I there a way for parsing right now? Update: you can always subclass |
https://github.com/octet-stream/form-data is a spec compliant alternative to this package |
It would be awesome if this library acted a bit more like a serverside polyfill for FormData in the browser.
I am very willing to create PR's for the items below. (Hopefully with help).
Here are a list of things that are currently missing (Feel free to comment more):
Existing Methods
https://dvcs.w3.org/hg/xhr/raw-file/tip/Overview.html#dom-formdata-append
Other
This may be out of scope.
The text was updated successfully, but these errors were encountered: