MCPcopy
hub / github.com/facebook/react / submit

Function submit

packages/react-dom/src/__tests__/ReactDOMForm-test.js:187–208  ·  view source on GitHub ↗
(submitter)

Source from the content-addressed store, hash-verified

185 });
186
187 async function submit(submitter) {
188 await act(() => {
189 const form = submitter.form || submitter;
190 if (!submitter.form) {
191 submitter = undefined;
192 }
193 const submitEvent = new Event('submit', {
194 bubbles: true,
195 cancelable: true,
196 });
197 submitEvent.submitter = submitter;
198 const returnValue = form.dispatchEvent(submitEvent);
199 if (!returnValue) {
200 return;
201 }
202 const action =
203 (submitter && submitter.getAttribute('formaction')) || form.action;
204 if (!/\s*javascript:/i.test(action)) {
205 throw new Error('Navigate to: ' + action);
206 }
207 });
208 }
209
210 it('should allow passing a function to form action', async () => {
211 const ref = React.createRef();

Callers 2

OutputFunction · 0.70

Calls 2

actFunction · 0.70
testMethod · 0.45

Tested by

no test coverage detected