Skip to content

Commit

Permalink
fix: foxhound87#320 (rollback foxhound87#310)
Browse files Browse the repository at this point in the history
  • Loading branch information
foxhound87 committed Sep 3, 2017
1 parent 23fa1eb commit a613349
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 12 deletions.
1 change: 1 addition & 0 deletions demo
6 changes: 3 additions & 3 deletions src/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@ const handleFieldsArrayOfObjects = ($fields) => {
let fields = $fields;
// handle array of objects (with unified props)
if (utils.isArrayOfObjects(fields)) {
fields = _.reduce(fields, ($obj, $) => {
if (!_.has($, 'name')) return undefined;
return Object.assign($obj, { [$.name]: $ });
fields = _.reduce(fields, ($obj, field) => {
if (utils.hasUnifiedProps({ fields: { field } }) && !_.has(field, 'name')) return undefined;
return Object.assign($obj, { [field.name]: field });
}, {});
}
return fields;
Expand Down
2 changes: 0 additions & 2 deletions src/shared/Actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,10 +181,8 @@ export default {
delete obj[field.key]; // eslint-disable-line
if (removeValue) return obj;

const checkName = (k, v) => _.has(v, 'name') && (k === v.name);

const data = utils.hasUnifiedProps({ fields: [value] })
|| checkName(field.key, value)
? value[prop]
: value;

Expand Down
9 changes: 2 additions & 7 deletions tests/fixes.values.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,15 +211,10 @@ describe('Check Fixes $P values', () => {
describe('Check Fixes $R values', () => {
const a = $.$R.values().organization;
const b = $.$R.$('organization').value;
const x = { nested: undefined };

it('$R values().organization check', () =>
expect(a).to.be.deep.equal(x));
expect(a).to.be.deep.equal(b));

it('$R organization value check', () =>
expect(b).to.be.deep.equal(x));

it('$R values() check', () =>
expect($.$R.values()).to.be.deep
.equal({ organization: { nested: undefined } }));
expect(b).to.be.deep.equal(b));
});

0 comments on commit a613349

Please sign in to comment.