Skip to content

Commit ad76cf6

Browse files
author
Abraham Przewodnik
committed
Remove deferred.pipe
Remove the debugging-statement and revert dist/doc Remove deferred.pipe Remove the debugging-statement and revert dist/doc undo formatting
1 parent 0a8ac0a commit ad76cf6

File tree

3 files changed

+31
-23
lines changed

3 files changed

+31
-23
lines changed

src/parsley/base.js

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,20 @@ var Base = function () {
88
Base.prototype = {
99
asyncSupport: true, // Deprecated
1010

11-
_pipeAccordingToValidationResult: function () {
12-
var pipe = () => {
13-
var r = $.Deferred();
14-
if (true !== this.validationResult)
15-
r.reject();
16-
return r.resolve().promise();
17-
};
18-
return [pipe, pipe];
11+
_pipeAccordingToValidationResult: function (deferred) {
12+
return $.Deferred((newDefer) => {
13+
const handle = () => {
14+
var r = true === this.validationResult ?
15+
$.Deferred().resolve():
16+
$.Deferred().reject();
17+
r.promise()
18+
.progress(newDefer.notify)
19+
.done(newDefer.resolve)
20+
.fail(newDefer.reject)
21+
}
22+
deferred.done(handle)
23+
deferred.fail(handle)
24+
})
1925
},
2026

2127
actualizeOptions: function () {

src/parsley/field.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,13 @@ Field.prototype = {
6262
// Field Validate event. `this.value` could be altered for custom needs
6363
this._trigger('validate');
6464

65-
return this.whenValid({force, value: this.value, _refreshed: true})
66-
.always(() => { this._reflowUI(); })
67-
.done(() => { this._trigger('success'); })
68-
.fail(() => { this._trigger('error'); })
69-
.always(() => { this._trigger('validated'); })
70-
.pipe(...this._pipeAccordingToValidationResult());
65+
return this._pipeAccordingToValidationResult(
66+
this.whenValid({force, value: this.value, _refreshed: true})
67+
.always(() => { this._reflowUI(); })
68+
.done(() => { this._trigger('success'); })
69+
.fail(() => { this._trigger('error'); })
70+
.always(() => { this._trigger('validated'); })
71+
);
7172
},
7273

7374
hasConstraints: function () {

src/parsley/form.js

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -103,15 +103,16 @@ Form.prototype = {
103103
return $.map(this.fields, field => field.whenValidate({force, group}));
104104
});
105105

106-
return Utils.all(promises)
107-
.done( () => { this._trigger('success'); })
108-
.fail( () => {
109-
this.validationResult = false;
110-
this.focus();
111-
this._trigger('error');
112-
})
113-
.always(() => { this._trigger('validated'); })
114-
.pipe(...this._pipeAccordingToValidationResult());
106+
return this._pipeAccordingToValidationResult(
107+
Utils.all(promises)
108+
.done( () => { this._trigger('success'); })
109+
.fail( () => {
110+
this.validationResult = false;
111+
this.focus();
112+
this._trigger('error');
113+
})
114+
.always(() => { this._trigger('validated'); })
115+
);
115116
},
116117

117118
// Iterate over refreshed fields, and stop on first failure.

0 commit comments

Comments
 (0)