Skip to content

Commit 7658d06

Browse files
committed
Merge pull request christianalfoni#258 from sdemjanenko/fix_multiple_on_change
Fix multiple on change
2 parents b39fd2e + 1df3e35 commit 7658d06

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
lines changed

src/main.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -424,9 +424,23 @@ Formsy.Form = React.createClass({
424424
this.validateForm();
425425
},
426426
render: function () {
427+
var {
428+
mapping,
429+
validationErrors,
430+
onSubmit,
431+
onValid,
432+
onInvalid,
433+
onInvalidSubmit,
434+
onChange,
435+
reset,
436+
preventExternalInvalidation,
437+
onSuccess,
438+
onError,
439+
...nonFormsyProps
440+
} = this.props;
427441

428442
return (
429-
<form {...this.props} onSubmit={this.submit}>
443+
<form {...nonFormsyProps} onSubmit={this.submit}>
430444
{this.props.children}
431445
</form>
432446
);

tests/Formsy-spec.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ export default {
350350

351351
},
352352

353-
'should trigger onChange when form element is changed': function (test) {
353+
'should trigger onChange once when form element is changed': function (test) {
354354

355355
const hasChanged = sinon.spy();
356356
const form = TestUtils.renderIntoDocument(
@@ -359,12 +359,12 @@ export default {
359359
</Formsy.Form>
360360
);
361361
TestUtils.Simulate.change(TestUtils.findRenderedDOMComponentWithTag(form, 'INPUT'), {target: {value: 'bar'}});
362-
test.equal(hasChanged.called, true);
362+
test.equal(hasChanged.calledOnce, true);
363363
test.done();
364364

365365
},
366366

367-
'should trigger onChange when new input is added to form': function (test) {
367+
'should trigger onChange once when new input is added to form': function (test) {
368368

369369
const hasChanged = sinon.spy();
370370
const TestForm = React.createClass({
@@ -394,7 +394,7 @@ export default {
394394
const form = TestUtils.renderIntoDocument(<TestForm/>);
395395
form.addInput();
396396
immediate(() => {
397-
test.equal(hasChanged.called, true);
397+
test.equal(hasChanged.calledOnce, true);
398398
test.done();
399399
});
400400

0 commit comments

Comments
 (0)