-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add hasOwn into utils as safe replacement for hasOwnProperty
- Loading branch information
Showing
7 changed files
with
73 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { render } from '@testing-library/react' | ||
console.error = jest.fn() | ||
|
||
test('hasOwnProperty', async () => { | ||
'use strict' | ||
// Freeze Object.prototype to not accidentally export its properties again | ||
// see https://github.com/emotion-js/emotion/issues/3158 | ||
Object.freeze(Object.prototype) | ||
|
||
// Previous version: | ||
// const utils = (await import('../../dist/emotion-element-48d2c2e4.cjs.dev.js')) | ||
// .default | ||
|
||
// Current version: | ||
// const utils = (await import('../../dist/emotion-element-e909c831.cjs.dev')) | ||
// .default | ||
|
||
// console.log(utils) | ||
// expect( | ||
// Object.prototype.hasOwnProperty.call(utils, 'hasOwnProperty') | ||
// ).toBeFalsy() | ||
|
||
const element = await import('../../dist/emotion-react.worker.esm.js').default | ||
console.log(element) | ||
expect( | ||
Object.prototype.hasOwnProperty.call(element, 'hasOwnProperty') | ||
).toBeFalsy() | ||
|
||
// /** @jsx jsx */ | ||
// const { jsx } = await import('@emotion/react') | ||
// // const { CacheProvider } = await import('@emotion/react') | ||
// const { CacheProvider } = await import('../../dist/emotion-react.cjs.dev.js') | ||
// const createCache = await (await import('@emotion/cache')).default | ||
|
||
// const cache = createCache({ key: 'context' }) | ||
// render(<CacheProvider cache={cache} />) | ||
expect(console.error).not.toHaveBeenCalled() | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { render } from '@testing-library/react' | ||
console.error = jest.fn() | ||
|
||
test('hasOwnProperty', async () => { | ||
// Freeze Object.prototype to not accidentally export its properties again | ||
// see https://github.com/emotion-js/emotion/issues/3158 | ||
Object.freeze(Object.prototype) | ||
|
||
// const utils = (await import('../../dist/emotion-react.cjs.dev.js')).default | ||
// Previous version: | ||
// const utils = (await import('../../dist/emotion-element-48d2c2e4.cjs.dev.js')) | ||
// .default | ||
|
||
// Current version: | ||
const utils = (await import('../../dist/emotion-element-e909c831.cjs.dev')) | ||
.default | ||
|
||
expect( | ||
Object.prototype.hasOwnProperty.call(utils, 'hasOwnProperty') | ||
).toBeFalsy() | ||
|
||
expect(console.error).not.toHaveBeenCalled() | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
// @flow | ||
export let isBrowser = typeof document !== 'undefined' | ||
|
||
export const hasOwn = Object.hasOwn |