• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

validide / javascript-browser-utilities / 13384610121

18 Feb 2025 06:28AM UTC coverage: 100.0%. Remained the same
13384610121

push

github

validide
Bump serialize-javascript and mocha

Bumps [serialize-javascript](https://github.com/yahoo/serialize-javascript) to 6.0.2 and updates ancestor dependency [mocha](https://github.com/mochajs/mocha). These dependencies need to be updated together.


Updates `serialize-javascript` from 6.0.0 to 6.0.2
- [Release notes](https://github.com/yahoo/serialize-javascript/releases)
- [Commits](https://github.com/yahoo/serialize-javascript/compare/v6.0.0...v6.0.2)

Updates `mocha` from 10.2.0 to 10.8.2
- [Release notes](https://github.com/mochajs/mocha/releases)
- [Changelog](https://github.com/mochajs/mocha/blob/main/CHANGELOG.md)
- [Commits](https://github.com/mochajs/mocha/compare/v10.2.0...v10.8.2)

---
updated-dependencies:
- dependency-name: serialize-javascript
  dependency-type: indirect
- dependency-name: mocha
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <support@github.com>

162 of 162 branches covered (100.0%)

Branch coverage included in aggregate %.

373 of 373 relevant lines covered (100.0%)

17.32 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

100.0
/src/dom/form/appendDataToForm.ts
1
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
2
// eslint-disable-next-line prefer-arrow/prefer-arrow-functions
3
function appendInput(form: HTMLFormElement, name: string, value: string): void {
4
  const input = form.ownerDocument.createElement('input');
12✔
5
  input.name = name;
12✔
6
  input.value = value;
12✔
7
  input.type = 'hidden';
12✔
8
  form.appendChild(input);
12✔
9
}
10

11
// eslint-disable-next-line prefer-arrow/prefer-arrow-functions
12
function appendData(form: HTMLFormElement, data: any, parentProp: string): void {
13
  if (typeof data === 'object' && data != null) {
20✔
14
    if (data instanceof Date) {
9✔
15
      appendInput(form, parentProp, data.toISOString());
1✔
16
    } else {
17
      Object.keys(data as object).forEach(prop => {
8✔
18
        appendData(form, data[prop], parentProp ? `${parentProp}[${prop}]` : prop);
18✔
19
      });
20
    }
21
  } else {
22
    // eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-argument
23
    appendInput(form, parentProp, data === null || data === undefined ? '' : data.toString());
11✔
24
  }
25
}
26

27
/**
28
 * Append an object to a form as 'input'(HTMLInputElement) elements
29
 *
30
 * @param data The information to append to the the ´form´
31
 * @param form The form (HTMLFormElement) element to elements to
32
 * @throws {Error} if the ´form´ does not have an 'ownerDocument'
33
 */
34
// eslint-disable-next-line prefer-arrow/prefer-arrow-functions
35
function appendDataToForm(data: Record<string, unknown> | null, form: HTMLFormElement): void {
36
  if (!data)
7✔
37
    return;
4✔
38

39
  if (!form.ownerDocument)
3✔
40
    throw new Error('The "ownerDocument" of the "form" should be the a reference to the parent window!');
1✔
41

42
  appendData(form, data, '');
2✔
43
}
44

45
export { appendDataToForm };
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc