Skip to content

Commit

Permalink
fix(compat): remove references to window (#4651)
Browse files Browse the repository at this point in the history
fixes #4650
  • Loading branch information
Haroenv authored Feb 11, 2021
1 parent 36b2810 commit 1ede1ae
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions src/connectors/numeric-menu/connectNumericMenu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export type NumericMenuRendererOptionsItem = {
* URL encoded of the bounds object with the form `{start, end}`.
* This value can be used verbatim in the webpage and can be read by `refine`
* directly. If you want to inspect the value, you can do:
* `JSON.parse(window.decodeURI(value))` to get the object.
* `JSON.parse(decodeURI(value))` to get the object.
*/
value: string;

Expand Down Expand Up @@ -166,7 +166,7 @@ const connectNumericMenu: NumericMenuConnector = function connectNumericMenu(
const prepareItems = (state: SearchParameters) =>
items.map(({ start, end, label }) => ({
label,
value: (window as any).encodeURI(JSON.stringify({ start, end })),
value: encodeURI(JSON.stringify({ start, end })),
isRefined: isRefined(state, attribute, { start, end, label }),
}));

Expand Down Expand Up @@ -366,7 +366,7 @@ function getRefinedState(
) {
let resolvedState = state;

const refinedOption = JSON.parse((window as any).decodeURI(facetValue));
const refinedOption = JSON.parse(decodeURI(facetValue));

// @TODO: why is array / element mixed here & hasRefinements; seems wrong?
const currentRefinements = resolvedState.getNumericRefinements(
Expand Down
8 changes: 4 additions & 4 deletions stories/voice-search.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ storiesOf('Basics/VoiceSearch', module)
.add(
'with a custom button text',
withHits(({ search, container }) => {
const style = window.document.createElement('style');
window.document.head.appendChild(style);
const style = document.createElement('style');
document.head.appendChild(style);
[
`.ais-VoiceSearch-button.custom-button:hover {
background: inherit;
Expand Down Expand Up @@ -130,8 +130,8 @@ storiesOf('Basics/VoiceSearch', module)
container.appendChild(subContainer1);
container.appendChild(subContainer2);

const style = window.document.createElement('style');
window.document.head.appendChild(style);
const style = document.createElement('style');
document.head.appendChild(style);
[
`.voice-search-button {
position: absolute;
Expand Down

0 comments on commit 1ede1ae

Please sign in to comment.