File tree Expand file tree Collapse file tree 2 files changed +14
-4
lines changed
packages/material-ui-utils/src Expand file tree Collapse file tree 2 files changed +14
-4
lines changed Original file line number Diff line number Diff line change 1- export function isObject ( item ) {
2- return item && typeof item === 'object' && ! Array . isArray ( item ) ;
1+ export function isPlainObject ( item ) {
2+ return item && typeof item === 'object' && item . constructor === Object ;
33}
44
55export default function deepmerge ( target , source , options = { clone : true } ) {
66 const output = options . clone ? { ...target } : target ;
77
8- if ( isObject ( target ) && isObject ( source ) ) {
8+ if ( isPlainObject ( target ) && isPlainObject ( source ) ) {
99 Object . keys ( source ) . forEach ( key => {
1010 // Avoid prototype pollution
1111 if ( key === '__proto__' ) {
1212 return ;
1313 }
1414
15- if ( isObject ( source [ key ] ) && key in target ) {
15+ if ( isPlainObject ( source [ key ] ) && key in target ) {
1616 output [ key ] = deepmerge ( target [ key ] , source [ key ] , options ) ;
1717 } else {
1818 output [ key ] = source [ key ] ;
Original file line number Diff line number Diff line change @@ -9,4 +9,14 @@ describe('deepmerge', () => {
99 } ) ;
1010 expect ( { } . isAdmin ) . to . equal ( undefined ) ;
1111 } ) ;
12+
13+ // https://github.com/mui-org/material-ui/issues/20095
14+ it ( 'should not merge DOM elements' , ( ) => {
15+ const element = document . createElement ( 'div' ) ;
16+ const element2 = document . createElement ( 'div' ) ;
17+
18+ const result = deepmerge ( { element } , { element : element2 } ) ;
19+
20+ expect ( result . element ) . to . equal ( element2 ) ;
21+ } ) ;
1222} ) ;
You can’t perform that action at this time.
0 commit comments