-
Notifications
You must be signed in to change notification settings - Fork 24
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
feat(form-data): allow passing a form to FormData #26
Conversation
Signed-off-by: Logan McAnsh <logan@mcan.sh>
Signed-off-by: Logan McAnsh <logan@mcan.sh>
🦋 Changeset detectedLatest commit: 31a3c7d The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
93c70c4
to
72bfb03
Compare
Signed-off-by: Logan McAnsh <logan@mcan.sh>
72bfb03
to
48887cb
Compare
* @param {Element} element | ||
* @returns {element is HTMLSelectElement} | ||
*/ | ||
function isSelectElement(element) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these are only used once, might as well inline them?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
doing so loses out on some type checking as it doesn't do a element is HTMLSelectElement
assertion anymore Property 'value' does not exist on type 'Element'.
:/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TYPESCRIPT!!!!!!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i felt a jsdoc to typescript migration was a little 🤏 outside of the scope of this PR haha
Signed-off-by: Logan McAnsh <logan@mcan.sh>
Signed-off-by: Logan McAnsh <logan@mcan.sh>
Signed-off-by: Logan McAnsh <logan@mcan.sh>
Signed-off-by: Logan McAnsh <logan@mcan.sh>
@@ -259,4 +259,28 @@ export const test = (test) => { | |||
"rename.md" | |||
); | |||
}); | |||
|
|||
test("Should allow passing a form element", () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's drop the jsdom dev dependency and just make our own mock HTMLFormElement
that's got all the right methods/getters/etc. that we use.
@@ -7,7 +7,7 @@ import { assert } from "./test.js"; | |||
* @param {import('./test').Test} test | |||
*/ | |||
export const test = (test) => { | |||
test("test baisc", async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BAISC!
Signed-off-by: Logan McAnsh <logan@mcan.sh>
checked: true, | ||
} | ||
] | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need Object.prototype.toString.call(value) === "[object HTMLFormElement]";
to evaluate correctly.
class FakeForm {
get [Symbol.toStringTag]() {
return "HTMLFormElement";
}
get elements() {
return [/* ... */]
}
get id() {
return "my-form"
}
}
let form = new FakeForm();
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/toStringTag
Signed-off-by: Logan McAnsh <logan@mcan.sh>
54484a9
to
1b0c009
Compare
Signed-off-by: Logan McAnsh <logan@mcan.sh>
5f92aee
to
2af3c8d
Compare
Signed-off-by: Logan McAnsh <logan@mcan.sh>
2af3c8d
to
31a3c7d
Compare
No description provided.