Skip to content

Commit 88497e5

Browse files
authored
fix(ie): do not rely on Object.assign (#2885)
* docs(CONTRIBUTING): fix command for debugging func test app * test(functional): use routing instead of urlSync * fix(ie): do not rely on Object.assign * chore(lint): fix lint * refactor(functional-test): remove recorded search data
1 parent 4772936 commit 88497e5

File tree

5 files changed

+28
-84
lines changed

5 files changed

+28
-84
lines changed

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ the test page with your VM. **Do not commit this change**
293293
```
294294

295295
Then you should be able debug using the dev setup: `yarn run dev` and the virtual machine. You can also
296-
run the page used for function tests using `yarn run test:functional:dev:debug`
296+
run the page used for function tests using `yarn run test:functional:dev:debug-server`
297297

298298
## Linting ✨
299299

functional-tests/app/app.js

Lines changed: 1 addition & 57 deletions
Large diffs are not rendered by default.

src/lib/RoutingManager.js

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,13 @@ export default class RoutingManager {
3131
currentConfiguration.index,
3232
currentConfiguration
3333
).state;
34-
return Object.assign(
35-
{},
36-
this.getAllSearchParameters({
34+
// The content of getAllSearchParameters is destructured to return a plain object
35+
return {
36+
...this.getAllSearchParameters({
3737
currentSearchParameters: this.originalConfig,
3838
uiState: this.originalUIState,
39-
})
40-
);
39+
}),
40+
};
4141
}
4242

4343
render({ state }) {
@@ -63,11 +63,10 @@ export default class RoutingManager {
6363
uiState,
6464
});
6565

66-
const fullHelperState = Object.assign(
67-
{},
68-
this.originalConfig,
69-
searchParameters
70-
);
66+
const fullHelperState = {
67+
...this.originalConfig,
68+
...searchParameters,
69+
};
7170

7271
if (isEqual(fullHelperState, searchParameters)) return;
7372

@@ -162,11 +161,10 @@ export default class RoutingManager {
162161
uiState,
163162
});
164163

165-
const fullSearchParameters = Object.assign(
166-
{},
167-
this.originalConfig,
168-
searchParameters
169-
);
164+
const fullSearchParameters = {
165+
...this.originalConfig,
166+
...searchParameters,
167+
};
170168

171169
fn(fullSearchParameters);
172170
});

src/lib/url-sync.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import algoliasearchHelper from 'algoliasearch-helper';
22
import urlHelper from 'algoliasearch-helper/src/url';
33
import isEqual from 'lodash/isEqual';
4-
import assign from 'lodash/assign';
54

65
const AlgoliaSearchHelper = algoliasearchHelper.AlgoliaSearchHelper;
76

@@ -162,7 +161,10 @@ class URLSync {
162161
clearTimeout(this.urlUpdateTimeout);
163162
// compare with helper.state
164163
const partialHelperState = helper.getState(this.trackedParameters);
165-
const fullHelperState = assign({}, this.originalConfig, partialHelperState);
164+
const fullHelperState = {
165+
...this.originalConfig,
166+
...partialHelperState,
167+
};
166168

167169
if (isEqual(fullHelperState, fullState)) return;
168170

@@ -215,7 +217,10 @@ class URLSync {
215217
qs,
216218
{ mapping: this.mapping }
217219
);
218-
const fullState = assign({}, this.originalConfig, partialState);
220+
const fullState = {
221+
...this.originalConfig,
222+
...partialState,
223+
};
219224
fn(fullState);
220225
});
221226
}

src/widgets/analytics/analytics.js

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -131,14 +131,11 @@ function analytics({
131131

132132
let formattedParams = [];
133133

134-
const serializedRefinements = serializeRefinements(
135-
Object.assign(
136-
{},
137-
state.state.disjunctiveFacetsRefinements,
138-
state.state.facetsRefinements,
139-
state.state.hierarchicalFacetsRefinements
140-
)
141-
);
134+
const serializedRefinements = serializeRefinements({
135+
...state.state.disjunctiveFacetsRefinements,
136+
...state.state.facetsRefinements,
137+
...state.state.hierarchicalFacetsRefinements,
138+
});
142139

143140
const serializedNumericRefinements = serializeNumericRefinements(
144141
state.state.numericRefinements

0 commit comments

Comments
 (0)