Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit b2695fd

Browse files
Merge pull request #1383 from CYBAI/fix-1381
Get value from key first; if not existing, try recursive get
2 parents 2c3e39e + 8b6992b commit b2695fd

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

‎packages/react-bootstrap-table2/src/utils.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ function splitNested(str) {
1212
}
1313

1414
function get(target, field) {
15+
const directGet = target[field];
16+
if (directGet !== undefined && directGet !== null) {
17+
return directGet;
18+
}
19+
1520
const pathArray = splitNested(field);
1621
let result;
1722
try {

‎packages/react-bootstrap-table2/test/utils.test.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ describe('Utils', () => {
1010
city: {
1111
name: 'B'
1212
}
13-
}
13+
},
14+
'person.name': 'John Doe'
1415
};
1516

1617
it('should return correct data', () => {
@@ -19,6 +20,7 @@ describe('Utils', () => {
1920
expect(_.get(data, 'address.city.name')).toEqual(data.address.city.name);
2021
expect(_.get(data, 'address.notExist')).toEqual(undefined);
2122
expect(_.get(data, 'address.not.exist')).toEqual(undefined);
23+
expect(_.get(data, 'person.name')).toEqual(data['person.name']);
2224
});
2325
});
2426

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /