File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -234,6 +234,7 @@ export function transform(
234234 }
235235
236236 let needGetPrototypeOf = false
237+ let needHasOwn = false
237238
238239 if ( program . scope . hasGlobal ( `Object` ) ) {
239240 for ( const referencePath of getReferencePathsToGlobal ( `Object` , program ) ) {
@@ -243,6 +244,9 @@ export function transform(
243244 if ( referencePath . parent . property . name == `getPrototypeOf` ) {
244245 referencePath . parentPath . replaceWith ( t . identifier ( `_${ uniqueId } _GET_PROTOTYPE_OF_` ) )
245246 needGetPrototypeOf = true
247+ } else if ( referencePath . parent . property . name == `hasOwn` ) {
248+ referencePath . parentPath . replaceWith ( t . identifier ( `_${ uniqueId } _HAS_OWN_` ) )
249+ needHasOwn = true
246250 }
247251 }
248252 }
@@ -568,6 +572,31 @@ export function transform(
568572 ] ) )
569573 }
570574
575+ if ( needHasOwn ) {
576+ mainFunction . body . body . unshift ( t . variableDeclaration ( `let` , [
577+ t . variableDeclarator (
578+ t . identifier ( `_${ uniqueId } _HAS_OWN_` ) ,
579+ t . callExpression (
580+ t . memberExpression (
581+ t . memberExpression (
582+ t . identifier (
583+ globalFunctionsUnder7Characters . find ( name => ! program . scope . hasOwnBinding ( name ) ) !
584+ ) ,
585+ t . identifier ( `call` )
586+ ) ,
587+ t . identifier ( `bind` )
588+ ) ,
589+ [
590+ t . memberExpression (
591+ t . memberExpression ( t . identifier ( `Object` ) , t . identifier ( `prototype` ) ) ,
592+ t . identifier ( `hasOwnProperty` )
593+ )
594+ ]
595+ )
596+ )
597+ ] ) )
598+ }
599+
571600 if ( consoleMethodsReferenced . size ) {
572601 mainFunction . body . body . unshift ( t . variableDeclaration (
573602 `let` ,
You can’t perform that action at this time.
0 commit comments