mki-formsy-react
Advanced tools
Comparing version 0.19.0 to 0.20.0
@@ -37,7 +37,7 @@ 'use strict'; | ||
return { | ||
_value: this.props.value, | ||
_value: this._getPristineValue(), | ||
_isRequired: false, | ||
_isValid: true, | ||
_isPristine: true, | ||
_pristineValue: this.props.value, | ||
_pristineValue: this._getPristineValue(), | ||
_validationError: [], | ||
@@ -48,2 +48,6 @@ _externalError: null, | ||
}, | ||
_getPristineValue: function _getPristineValue() { | ||
// matches React https://github.com/facebook/react/blob/d684b1598d16936f9539b48310fa4584193063cb/src/renderers/dom/client/wrappers/ReactDOMInput.js#L79 | ||
return this.props.value != null ? this.props.value : this.props.defaultValue; | ||
}, | ||
contextTypes: { | ||
@@ -50,0 +54,0 @@ formsy: React.PropTypes.object // What about required? |
{ | ||
"name": "mki-formsy-react", | ||
"version": "0.19.0", | ||
"version": "0.20.0", | ||
"description": "A form input builder and validator for React JS", | ||
@@ -5,0 +5,0 @@ "repository": { |
@@ -1,2 +0,2 @@ | ||
formsy-react [![GitHub release](https://img.shields.io/github/release/christianalfoni/formsy-react.svg)](https://github.com/christianalfoni/formsy-react/releases) [![Build Status](https://travis-ci.org/christianalfoni/formsy-react.svg?branch=master)](https://travis-ci.org/christianalfoni/formsy-react) | ||
mki-formsy-react [![GitHub release](https://img.shields.io/npm/v/mki-formsy-react.svg)](https://www.npmjs.com/package/mki-formsy-react) | ||
============ | ||
@@ -3,0 +3,0 @@ |
@@ -36,7 +36,7 @@ var utils = require('./utils.js'); | ||
return { | ||
_value: this.props.value, | ||
_value: this._getPristineValue(), | ||
_isRequired: false, | ||
_isValid: true, | ||
_isPristine: true, | ||
_pristineValue: this.props.value, | ||
_pristineValue: this._getPristineValue(), | ||
_validationError: [], | ||
@@ -47,2 +47,6 @@ _externalError: null, | ||
}, | ||
_getPristineValue: function() { | ||
// matches React https://github.com/facebook/react/blob/d684b1598d16936f9539b48310fa4584193063cb/src/renderers/dom/client/wrappers/ReactDOMInput.js#L79 | ||
return this.props.value != null ? this.props.value : this.props.defaultValue; | ||
}, | ||
contextTypes: { | ||
@@ -49,0 +53,0 @@ formsy: React.PropTypes.object // What about required? |
@@ -30,2 +30,54 @@ import React from 'react'; | ||
'should set _pristineValue to the passed value': function(test) { | ||
const form = TestUtils.renderIntoDocument( | ||
<Formsy.Form> | ||
<TestInput name="foo" value="foo"/> | ||
</Formsy.Form> | ||
); | ||
const input = TestUtils.findRenderedComponentWithType(form, TestInput); | ||
test.equal(input.state._pristineValue, 'foo'); | ||
test.done(); | ||
}, | ||
'should set _pristineValue to the passed defaultValue': function(test) { | ||
const form = TestUtils.renderIntoDocument( | ||
<Formsy.Form> | ||
<TestInput name="foo" defaultValue="foo"/> | ||
</Formsy.Form> | ||
); | ||
const input = TestUtils.findRenderedComponentWithType(form, TestInput); | ||
test.equal(input.state._pristineValue, 'foo'); | ||
test.done(); | ||
}, | ||
'should set _value to the passed value': function(test) { | ||
const form = TestUtils.renderIntoDocument( | ||
<Formsy.Form> | ||
<TestInput name="foo" value="foo"/> | ||
</Formsy.Form> | ||
); | ||
const input = TestUtils.findRenderedComponentWithType(form, TestInput); | ||
test.equal(input.state._value, 'foo'); | ||
test.done(); | ||
}, | ||
'should set _value to the passed defaultValue': function(test) { | ||
const form = TestUtils.renderIntoDocument( | ||
<Formsy.Form> | ||
<TestInput name="foo" defaultValue="foo"/> | ||
</Formsy.Form> | ||
); | ||
const input = TestUtils.findRenderedComponentWithType(form, TestInput); | ||
test.equal(input.state._value, 'foo'); | ||
test.done(); | ||
}, | ||
'should set back to pristine value when running reset': function (test) { | ||
@@ -32,0 +84,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
313014
4471