Skip to content
This repository was archived by the owner on Dec 25, 2017. It is now read-only.

Commit cceabb8

Browse files
committed
✨ release(patch): v2.1.2
1 parent b1add7d commit cceabb8

8 files changed

+131
-107
lines changed

CHANGELOG.md

+24
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,27 @@
1+
<a name="2.1.2"></a>
2+
## [2.1.2](https://github.com/vuejs/vue-validator/compare/v2.1.1...v2.1.2) (2016-05-21)
3+
4+
5+
### :bug: Bug Fixes
6+
7+
* **cleanup:** fix cannot get validation result ([33c71d1](https://github.com/vuejs/vue-validator/commit/33c71d1))
8+
* **errors:** fix cannot apply validation classes ([af91d57](https://github.com/vuejs/vue-validator/commit/af91d57)), closes [#239](https://github.com/vuejs/vue-validator/issues/239)
9+
* **event:** fix cannot fire top level events ([b91d36a](https://github.com/vuejs/vue-validator/commit/b91d36a)), closes [#233](https://github.com/vuejs/vue-validator/issues/233)
10+
* **group:** fix group validation for radio ([1fbfc53](https://github.com/vuejs/vue-validator/commit/1fbfc53)), closes [#234](https://github.com/vuejs/vue-validator/issues/234)
11+
12+
13+
### :zap: Improvements
14+
15+
* **async:** update async validator for function I/F ([974cf61](https://github.com/vuejs/vue-validator/commit/974cf61))
16+
* **errors:** error messages order ([b1add7d](https://github.com/vuejs/vue-validator/commit/b1add7d)), closes [#240](https://github.com/vuejs/vue-validator/issues/240)
17+
* **warning:** changed warning for when the elements under validation are not wrapped in a <validator> element. ([#224](https://github.com/vuejs/vue-validator/issues/224)) by [@SERVANT14](https://github.com/SERVANT14) ([ec1f223](https://github.com/vuejs/vue-validator/commit/ec1f223))
18+
19+
20+
### NOTE
21+
22+
* cleanup: warning: not fixes validation result outside available yet
23+
24+
125
<a name="2.1.1"></a>
226
## [2.1.1](https://github.com/vuejs/vue-validator/compare/v2.1.0...v2.1.1) (2016-05-02)
327

dist/vue-validator.common.js

+50-50
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
* vue-validator v2.1.1
2+
* vue-validator v2.1.2
33
* (c) 2016 kazuya kawaguchi
44
* Released under the MIT License.
55
*/
@@ -567,7 +567,7 @@ function Validate (Vue) {
567567
var el = this.el;
568568

569569
if (process.env.NODE_ENV !== 'production' && el.__vue__) {
570-
warn('v-validate="' + this.expression + '" cannot be ' + 'used on an instance root element.');
570+
warn('v-validate="' + this.expression + '" cannot be used on an instance root element.');
571571
this._invalid = true;
572572
return;
573573
}
@@ -1245,28 +1245,13 @@ var BaseValidation = function () {
12451245
var future = validator.call(this, val, arg);
12461246
if (typeof future === 'function') {
12471247
// function
1248-
if (future.resolved) {
1249-
// cached
1250-
cb(future.resolved);
1251-
} else if (future.requested) {
1252-
// pool callbacks
1253-
future.pendingCallbacks.push(cb);
1254-
} else {
1255-
(function () {
1256-
future.requested = true;
1257-
var cbs = future.pendingCallbacks = [cb];
1258-
future(function () {
1259-
// resolve
1260-
future.resolved = true;
1261-
for (var i = 0, l = cbs.length; i < l; i++) {
1262-
cbs[i](true);
1263-
}
1264-
}, function (msg) {
1265-
// reject
1266-
cb(false, msg);
1267-
});
1268-
})();
1269-
}
1248+
future(function () {
1249+
// resolve
1250+
cb(true);
1251+
}, function (msg) {
1252+
// reject
1253+
cb(false, msg);
1254+
});
12701255
} else if (isPromise(future)) {
12711256
// promise
12721257
future.then(function () {
@@ -1845,20 +1830,31 @@ var Validator$1 = function () {
18451830

18461831
Validator.prototype.disableReactive = function disableReactive() {
18471832
var vm = this._dir.vm;
1848-
vm.$setValidationErrors = undefined;
1849-
vm.$validate = undefined;
1850-
vm.$validatorReset = undefined;
1833+
vm.$setValidationErrors = null;
1834+
delete vm['$setValidationErrors'];
1835+
vm.$validate = null;
1836+
delete vm['$validate'];
1837+
vm.$validatorReset = null;
1838+
delete vm['$validatorReset'];
18511839
vm._validatorMaps[this.name] = null;
1840+
delete vm._validatorMaps[this.name];
18521841
vm[this.name] = null;
1842+
delete vm[this.name];
18531843
};
18541844

18551845
Validator.prototype.registerEvents = function registerEvents() {
1846+
var isSimplePath = exports$1.Vue.parsers.expression.isSimplePath;
1847+
18561848
var attrs = this._dir.el.attributes;
18571849
for (var i = 0, l = attrs.length; i < l; i++) {
18581850
var event = attrs[i].name;
18591851
if (REGEX_EVENT.test(event)) {
1852+
var value = attrs[i].value;
1853+
if (isSimplePath(value)) {
1854+
value += '.apply(this, $arguments)';
1855+
}
18601856
event = event.replace(REGEX_EVENT, '');
1861-
this._events[this._getEventName(event)] = this._dir.vm.$eval(attrs[i].value, true);
1857+
this._events[this._getEventName(event)] = this._dir.vm.$eval(value, true);
18621858
}
18631859
}
18641860
};
@@ -1905,14 +1901,14 @@ var Validator$1 = function () {
19051901
Validator.prototype.addGroupValidation = function addGroupValidation(group, field) {
19061902
var indexOf = exports$1.Vue.util.indexOf;
19071903

1908-
var validation = this._validations[field] || this._checkboxValidations[field].validation || this._radioValidations[field].validation;
1904+
var validation = this._getValidationFrom(field);
19091905
var validations = this._groupValidations[group];
19101906

19111907
validations && ! ~indexOf(validations, validation) && validations.push(validation);
19121908
};
19131909

19141910
Validator.prototype.removeGroupValidation = function removeGroupValidation(group, field) {
1915-
var validation = this._validations[field] || this._checkboxValidations[field].validation || this._radioValidations[field].validation;
1911+
var validation = this._getValidationFrom(field);
19161912
var validations = this._groupValidations[group];
19171913

19181914
validations && pull(validations, validation);
@@ -2057,13 +2053,7 @@ var Validator$1 = function () {
20572053
};
20582054

20592055
Validator.prototype._getValidationFrom = function _getValidationFrom(field) {
2060-
var validation = this._validations[field];
2061-
if (!validation && this._checkboxValidations[field]) {
2062-
validation = this._checkboxValidations[field].validation;
2063-
} else if (!validation && this._radioValidations[field]) {
2064-
validation = this._radioValidations[field].validation;
2065-
}
2066-
return validation;
2056+
return this._validations[field] || this._checkboxValidations[field] && this._checkboxValidations[field].validation || this._radioValidations[field] && this._radioValidations[field].validation;
20672057
};
20682058

20692059
Validator.prototype._resetValidation = function _resetValidation(cb) {
@@ -2079,6 +2069,7 @@ var Validator$1 = function () {
20792069
var extend = exports$1.Vue.util.extend;
20802070

20812071
// make tempolaly errors
2072+
20822073
var temp = {};
20832074
each(errors, function (error, index) {
20842075
if (!temp[error.field]) {
@@ -2089,18 +2080,24 @@ var Validator$1 = function () {
20892080

20902081
// set errors
20912082
each(temp, function (values, field) {
2092-
var validation = _this9._scope[field];
2093-
var newValidation = {};
2083+
var results = _this9._scope[field];
2084+
var newResults = {};
2085+
20942086
each(values, function (error) {
20952087
if (error.validator) {
2096-
validation[error.validator] = error.message;
2088+
results[error.validator] = error.message;
20972089
}
20982090
});
2099-
validation.valid = false;
2100-
validation.invalid = true;
2101-
validation.errors = values;
2102-
extend(newValidation, validation);
2103-
exports$1.Vue.set(_this9._scope, field, newValidation);
2091+
2092+
results.valid = false;
2093+
results.invalid = true;
2094+
results.errors = values;
2095+
extend(newResults, results);
2096+
2097+
var validation = _this9._getValidationFrom(field);
2098+
validation.willUpdateClasses(newResults, validation.el);
2099+
2100+
exports$1.Vue.set(_this9._scope, field, newResults);
21042101
});
21052102
};
21062103

@@ -2189,13 +2186,14 @@ var Validator$1 = function () {
21892186
};
21902187

21912188
Validator.prototype._fireEvent = function _fireEvent(type) {
2192-
var handler = this._events[this._getEventName(type)];
2193-
21942189
for (var _len2 = arguments.length, args = Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
21952190
args[_key2 - 1] = arguments[_key2];
21962191
}
21972192

2198-
handler && handler.apply(null, args);
2193+
var handler = this._events[this._getEventName(type)];
2194+
handler && this._dir.vm.$nextTick(function () {
2195+
handler.apply(null, args);
2196+
});
21992197
};
22002198

22012199
Validator.prototype._fireEvents = function _fireEvents() {
@@ -2330,7 +2328,9 @@ var Validator$1 = function () {
23302328
}
23312329
});
23322330

2333-
return empty(errors) ? undefined : errors;
2331+
return empty(errors) ? undefined : errors.sort(function (a, b) {
2332+
return a.field < b.field ? -1 : 1;
2333+
});
23342334
};
23352335

23362336
babelHelpers.createClass(Validator, [{
@@ -2587,7 +2587,7 @@ function plugin(Vue) {
25872587
Validate(Vue);
25882588
}
25892589

2590-
plugin.version = '2.1.1';
2590+
plugin.version = '2.1.2';
25912591

25922592
if (typeof window !== 'undefined' && window.Vue) {
25932593
window.Vue.use(plugin);

0 commit comments

Comments
 (0)