Comparing version 0.15.4 to 0.16.0
# History | ||
---- | ||
## 0.16.0 / 2016-05-19 | ||
- move instance to this.instances | ||
## 0.15.0 / 2016-03-28 | ||
@@ -5,0 +9,0 @@ |
@@ -53,2 +53,3 @@ 'use strict'; | ||
this.fields = fields || {}; | ||
this.instances = {}; | ||
this.fieldsMeta = {}; | ||
@@ -62,14 +63,3 @@ this.cachedBind = {}; | ||
if (mapPropsToFields) { | ||
var fields = mapPropsToFields(nextProps); | ||
if (fields) { | ||
var instanceFields = this.fields = _extends({}, this.fields); | ||
for (var fieldName in fields) { | ||
if (fields.hasOwnProperty(fieldName)) { | ||
instanceFields[fieldName] = _extends({}, fields[fieldName], { | ||
// keep instance | ||
instance: instanceFields[fieldName] && instanceFields[fieldName].instance | ||
}); | ||
} | ||
} | ||
} | ||
this.fields = mapPropsToFields(nextProps); | ||
} | ||
@@ -262,5 +252,3 @@ }, | ||
getFieldInstance: function getFieldInstance(name) { | ||
var fields = this.fields; | ||
return fields[name] && fields[name].instance; | ||
return this.instances[name]; | ||
}, | ||
@@ -289,8 +277,2 @@ getValueFromFields: function getValueFromFields(name, fields) { | ||
var originalFields = this.fields; | ||
// reserve `instance` | ||
Object.keys(fields).forEach(function (key) { | ||
if (!originalFields[key]) return; | ||
fields[key].instance = originalFields[key].instance; | ||
}); | ||
var nowFields = _extends({}, originalFields, fields); | ||
@@ -358,2 +340,3 @@ var fieldsMeta = this.fieldsMeta; | ||
delete this.fields[name]; | ||
delete this.instances[name]; | ||
return; | ||
@@ -368,4 +351,3 @@ } | ||
} | ||
this.fields[name] = this.fields[name] || {}; | ||
this.fields[name].instance = component; | ||
this.instances[name] = component; | ||
}, | ||
@@ -389,4 +371,3 @@ validateFieldsInternal: function validateFieldsInternal(fields, _ref, callback) { | ||
alreadyErrors[name] = { | ||
errors: field.errors, | ||
instance: field.instance | ||
errors: field.errors | ||
}; | ||
@@ -441,4 +422,3 @@ } | ||
expired.push({ | ||
name: name, | ||
instance: nowField.instance | ||
name: name | ||
}); | ||
@@ -452,5 +432,2 @@ } else { | ||
} | ||
if (fieldErrors) { | ||
fieldErrors.instance = nowField.instance; | ||
} | ||
}); | ||
@@ -462,3 +439,2 @@ _this4.setFields(nowAllFields); | ||
var name = _ref2.name; | ||
var instance = _ref2.instance; | ||
@@ -471,3 +447,2 @@ var fieldErrors = [{ | ||
expired: true, | ||
instance: instance, | ||
errors: fieldErrors | ||
@@ -474,0 +449,0 @@ }; |
@@ -72,2 +72,4 @@ 'use strict'; | ||
validateFieldsAndScroll: function validateFieldsAndScroll(ns, opt, cb) { | ||
var _this = this; | ||
var _getParams = (0, _utils.getParams)(ns, opt, cb); | ||
@@ -80,3 +82,3 @@ | ||
function newCb(error, values) { | ||
var newCb = function newCb(error, values) { | ||
if (error) { | ||
@@ -86,8 +88,11 @@ var firstNode = void 0; | ||
for (var name in error) { | ||
if (error.hasOwnProperty(name) && error[name].instance) { | ||
var node = _reactDom2["default"].findDOMNode(error[name].instance); | ||
var top = node.getBoundingClientRect().top; | ||
if (firstTop === undefined || firstTop > top) { | ||
firstTop = top; | ||
firstNode = node; | ||
if (error.hasOwnProperty(name)) { | ||
var instance = _this.getFieldInstance(name); | ||
if (instance) { | ||
var node = _reactDom2["default"].findDOMNode(instance); | ||
var top = node.getBoundingClientRect().top; | ||
if (firstTop === undefined || firstTop > top) { | ||
firstTop = top; | ||
firstNode = node; | ||
} | ||
} | ||
@@ -107,3 +112,3 @@ } | ||
} | ||
} | ||
}; | ||
@@ -110,0 +115,0 @@ return this.validateFields(names, options, newCb); |
{ | ||
"name": "rc-form", | ||
"version": "0.15.4", | ||
"version": "0.16.0", | ||
"description": "React High Order Form Component", | ||
@@ -27,6 +27,3 @@ "keywords": [ | ||
"config": { | ||
"port": 8000, | ||
"commitizen": { | ||
"path": "./node_modules/cz-conventional-changelog" | ||
} | ||
"port": 8000 | ||
}, | ||
@@ -48,3 +45,2 @@ "scripts": { | ||
"async": "^1.5.2", | ||
"cz-conventional-changelog": "^1.1.5", | ||
"expect.js": "0.3.x", | ||
@@ -51,0 +47,0 @@ "history": "^1.16.0", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
13
260214
4902