Skip to content

Commit

Permalink
Merge pull request #1137 from armandabric/task/1136-invert-from-data-…
Browse files Browse the repository at this point in the history
…foreach-callback-parameters

#1136@patch: Fix FormData.forEach callback parameters order.
  • Loading branch information
capricorn86 authored Oct 26, 2023
2 parents f7dab33 + c43cfcb commit 8ed0db0
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/happy-dom/src/form-data/FormData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export default class FormData implements Iterable<[string, string | File]> {
*/
public forEach(callback: (key: string, value: string | File, thisArg: FormData) => void): void {
for (const entry of this._entries) {
callback.call(this, entry.name, entry.value, this);
callback.call(this, entry.value, entry.name, this);
}
}

Expand Down
2 changes: 1 addition & 1 deletion packages/happy-dom/test/form-data/FormData.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ describe('FormData', () => {
formData.set('key2', 'value2');
const values: Array<{ key: string; value: string | File }> = [];

formData.forEach((key, value) => values.push({ key, value }));
formData.forEach((value, key) => values.push({ key, value }));

expect(values).toEqual([
{ key: 'key1', value: 'value1' },
Expand Down
2 changes: 1 addition & 1 deletion packages/happy-dom/test/window/Window.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -868,7 +868,7 @@ describe('Window', () => {
window.setTimeout(async () => {
await new Promise((resolve) => setTimeout(resolve, 0));
throw new window.Error('Test error');
});
}, 5);
setTimeout(() => {
expect((<ErrorEvent>(<unknown>errorEvent)).error).instanceOf(window.Error);
expect((<ErrorEvent>(<unknown>errorEvent)).error?.message).toBe('Test error');
Expand Down

0 comments on commit 8ed0db0

Please sign in to comment.