Skip to content

Commit

Permalink
fix(Field): init values with parseName=false
Browse files Browse the repository at this point in the history
  • Loading branch information
jdkahn committed May 23, 2019
1 parent 86a6699 commit 0c92cfb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/field/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ class Field {
].forEach(m => {
this[m] = this[m].bind(this);
});

if (options.values) {
this.setValues(options.values, false);
}
}

setOptions(options) {
Expand Down
10 changes: 10 additions & 0 deletions test/field/options-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,16 @@ describe('options', () => {
assert.equal(field.getValue('input.child'), inputValue);
});

it('should support default `values` in constructor and access before init', function() {
const inputValue = 'my value';
const field = new Field(this, {
values: {
input: inputValue
}
});
assert.equal(field.getValue('input'), inputValue);
});

describe('should support parseName', () => {
it('getValues', function(done) {
const field = new Field(this, { parseName: true });
Expand Down

0 comments on commit 0c92cfb

Please sign in to comment.