Skip to content

Commit 80f8586

Browse files
committed
Ignore HTML elements without type
1 parent 4b2ba78 commit 80f8586

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

packages/react-form-with-constraints/src/FormWithConstraints.test.tsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1263,6 +1263,19 @@ describe('validate', () => {
12631263

12641264
wrapper.unmount();
12651265
});
1266+
1267+
test('Ignore elements without type', async () => {
1268+
const wrapper = mount(
1269+
<FormWithConstraints>
1270+
<iframe src="https://www.google.com/recaptcha..." name="a-49ekipqfmwsv" />
1271+
</FormWithConstraints>
1272+
);
1273+
const form = wrapper.instance() as FormWithConstraints;
1274+
1275+
await expect(form.validateFields()).resolves.toEqual([]);
1276+
1277+
wrapper.unmount();
1278+
});
12661279
});
12671280
});
12681281

packages/react-form-with-constraints/src/FormWithConstraints.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,10 @@ export class FormWithConstraints
127127
// See Convert JavaScript NodeList to Array? https://stackoverflow.com/a/33822526/990356
128128
inputs = [...this.form!.querySelectorAll<HTMLInputElement>('[name]')];
129129

130+
// Remove elements that don't have a type, example:
131+
// <iframe src="https://www.google.com/recaptcha..." name="a-49ekipqfmwsv">
132+
inputs = inputs.filter(input => input.type);
133+
130134
// Check we have unique names
131135
inputs
132136
.filter(input => input.type !== 'checkbox' && input.type !== 'radio')

0 commit comments

Comments
 (0)