Skip to content

Commit cb82b33

Browse files
committed
[evcohen/eslint-plugin-jsx-a11y#399] Accommodate ExperimentalSpreadProperty in prop values
1 parent a1e5007 commit cb82b33

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

__tests__/src/getPropValue-test.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -777,6 +777,15 @@ describe('getPropValue', () => {
777777

778778
assert.deepEqual(expected, actual);
779779
});
780+
781+
it('should evaluate to a correct representation of the object, ignore spread properties', () => {
782+
const prop = extractProp('<div foo={{ pathname: manageRoute, state: {...data}}} />');
783+
784+
const expected = { pathname: 'manageRoute', state: {} };
785+
const actual = getPropValue(prop);
786+
787+
assert.deepEqual(expected, actual);
788+
});
780789
});
781790

782791
describe('New expression', () => {

src/values/expressions/ObjectExpression.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ import getValue from './index';
99
export default function extractValueFromObjectExpression(value) {
1010
return value.properties.reduce((obj, property) => {
1111
const object = Object.assign({}, obj);
12-
if (property.type === 'SpreadProperty') {
12+
// Support types: SpreadProperty and ExperimentalSpreadProperty
13+
if (/^(?:Experimental)?SpreadProperty$/.test(property.type)) {
1314
if (property.argument.type === 'ObjectExpression') {
1415
return Object.assign(object, extractValueFromObjectExpression(property.argument));
1516
}

0 commit comments

Comments
 (0)