@ -111,14 +111,14 @@ export const patch = (parent, functionName, handler, before = false, instead = f
const keyName = ` gm- ${ functionName } ` ;
if ( ! modIndex [ id ] [ keyName ] ) {
const original FunctionClone = Object . assign ( { } , parent ) [ functionName ] ;
const original = parent [ functionName ] ;
parent [ functionName ] = Object . assign ( generateNewFunction ( parent[ functionName ] , id , functionName , keyName ) , originalFunctionClone ) ;
parent [ functionName ] = Object . assign ( generateNewFunction ( original , id , functionName , keyName ) , originalFunctionClone ) ;
parent [ functionName ] . toString = ( ) => originalFunctionClone . toString ( ) ; // You cannot just set directly a.toString = b.toString like we used to because strange internal JS prototype things, so make a new function just to run original function
let toHarden = false ;
if ( isReactComponent ( parent[ functionName ] ) ) toHarden = true ;
if ( isReactComponent ( original ) ) toHarden = true ;
if ( parent . render ) {
if ( functionName !== 'render' ) {
patch ( parent , 'render' , ( ) => { } ) ; // Noop patch in component render to force harden
@ -127,7 +127,7 @@ export const patch = (parent, functionName, handler, before = false, instead = f
}
}
if ( parent[ functionName ] . displayName ? . endsWith ( 'Item' ) ) toHarden = false ;
if ( original . displayName ? . endsWith ( 'Item' ) ) toHarden = false ;
modIndex [ id ] [ keyName ] = {
before : [ ] ,
@ -135,7 +135,7 @@ export const patch = (parent, functionName, handler, before = false, instead = f
instead : [ ] ,
harden : toHarden ,
original : originalFunctionClone
original
} ;
}