Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove usage of RN's polyfillGlobal #373

Merged
merged 6 commits into from
Nov 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,19 @@ jobs:
name: Lint
command: yarn lint
test-js:
parameters:
react-native-version:
type: string
default: ''
executor: default
steps:
- *attach-workspace
- when:
condition: << parameters.react-native-version >>
steps:
- run:
name: Overriding react-native version
command: yarn add --dev react-native@<< parameters.react-native-version >>
- run:
name: Run Jest
command: yarn test
Expand Down
4 changes: 0 additions & 4 deletions __tests__/index-test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
jest.mock('react-native/Libraries/Utilities/PolyfillFunctions', () => ({
polyfillGlobal: jest.fn(),
}));

describe('Index', function () {
it("shouldn't apply URL and URLSearchParams on import", () => {
expect(global.REACT_NATIVE_URL_POLYFILL).toBeUndefined();
Expand Down
9 changes: 2 additions & 7 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import './js/ios10Fix';

import {polyfillGlobal} from 'react-native/Libraries/Utilities/PolyfillFunctions';

import {name, version} from './package.json';

export * from './js/URL';
Expand All @@ -10,9 +8,6 @@ export * from './js/URLSearchParams';
export function setupURLPolyfill() {
global.REACT_NATIVE_URL_POLYFILL = `${name}@${version}`;

polyfillGlobal('URL', () => require('./js/URL').URL);
polyfillGlobal(
'URLSearchParams',
() => require('./js/URLSearchParams').URLSearchParams,
);
global.URL = require('./js/URL').URL;
global.URLSearchParams = require('./js/URLSearchParams').URLSearchParams;
}