mirror of
https://github.com/zhigang1992/styled-components.git
synced 2026-01-12 22:52:39 +08:00
Add test for elements in isPlainObject and fix up check
This commit is contained in:
@@ -5,4 +5,4 @@ export default (x: any): boolean =>
|
||||
typeof x === 'object' &&
|
||||
(x.toString ? x.toString() : Object.prototype.toString.call(x)) === '[object Object]' &&
|
||||
/* check for reasonable markers that the object isn't an element for react & preact/compat */
|
||||
!(x.$$typeof && (x._owner || (x.__v && x.__o)));
|
||||
!(x.$$typeof && ('_owner' in x) || x.__v);
|
||||
|
||||
@@ -29,6 +29,10 @@ it('returns false for a React component', () => {
|
||||
expect(isPlainObject(Foo)).toEqual(false);
|
||||
});
|
||||
|
||||
it('returns false for a React element', () => {
|
||||
expect(isPlainObject(React.createElement('div'))).toEqual(false);
|
||||
});
|
||||
|
||||
it('returns true for an object literal created in a different context', () => {
|
||||
const context = vm.createContext({});
|
||||
vm.runInContext('object = {};', context);
|
||||
|
||||
Reference in New Issue
Block a user