@@ -32,6 +32,7 @@ const _WeakMap: typeof WeakMap = typeof WeakMap === "function" ? WeakMap : fail(
32
32
// [[Metadata]] internal slot
33
33
// https://rbuckton.github.io/reflect-metadata/#ordinary-object-internal-methods-and-internal-slots
34
34
const Metadata = new _WeakMap < any , Map < string | symbol | undefined , Map < any , any > > > ( ) ;
35
+ let hasSetMetadata = false ;
35
36
36
37
/**
37
38
* Applies a set of decorators to a target object.
@@ -336,7 +337,7 @@ export function defineMetadata(metadataKey: any, metadataValue: any, target: any
336
337
*
337
338
*/
338
339
export function defineMetadata ( metadataKey : any , metadataValue : any , target : any , propertyKey ?: string | symbol ) : void {
339
- if ( typeof Reflect !== "undefined" && typeof Reflect . defineMetadata === "function" && Reflect . defineMetadata !== defineMetadata ) {
340
+ if ( ! hasSetMetadata && typeof Reflect !== "undefined" && typeof Reflect . defineMetadata === "function" && Reflect . defineMetadata !== defineMetadata ) {
340
341
return Reflect . defineMetadata ( metadataKey , metadataValue , target , propertyKey ! ) ;
341
342
}
342
343
if ( ! IsObject ( target ) ) throw new TypeError ( ) ;
@@ -430,7 +431,7 @@ export function hasMetadata(metadataKey: any, target: any, propertyKey: string |
430
431
*
431
432
*/
432
433
export function hasMetadata ( metadataKey : any , target : any , propertyKey ?: string | symbol ) : boolean {
433
- if ( typeof Reflect !== "undefined" && typeof Reflect . hasMetadata === "function" && Reflect . hasMetadata !== hasMetadata ) {
434
+ if ( ! hasSetMetadata && typeof Reflect !== "undefined" && typeof Reflect . hasMetadata === "function" && Reflect . hasMetadata !== hasMetadata ) {
434
435
return Reflect . hasMetadata ( metadataKey , target , propertyKey ! ) ;
435
436
}
436
437
if ( ! IsObject ( target ) ) throw new TypeError ( ) ;
@@ -524,7 +525,7 @@ export function hasOwnMetadata(metadataKey: any, target: any, propertyKey: strin
524
525
*
525
526
*/
526
527
export function hasOwnMetadata ( metadataKey : any , target : any , propertyKey ?: string | symbol ) : boolean {
527
- if ( typeof Reflect !== "undefined" && typeof Reflect . hasOwnMetadata === "function" && Reflect . hasOwnMetadata !== hasOwnMetadata ) {
528
+ if ( ! hasSetMetadata && typeof Reflect !== "undefined" && typeof Reflect . hasOwnMetadata === "function" && Reflect . hasOwnMetadata !== hasOwnMetadata ) {
528
529
return Reflect . hasOwnMetadata ( metadataKey , target , propertyKey ! ) ;
529
530
}
530
531
if ( ! IsObject ( target ) ) throw new TypeError ( ) ;
@@ -618,7 +619,7 @@ export function getMetadata(metadataKey: any, target: any, propertyKey: string |
618
619
*
619
620
*/
620
621
export function getMetadata ( metadataKey : any , target : any , propertyKey ?: string | symbol ) : any {
621
- if ( typeof Reflect !== "undefined" && typeof Reflect . getMetadata === "function" && Reflect . getMetadata !== getMetadata ) {
622
+ if ( ! hasSetMetadata && typeof Reflect !== "undefined" && typeof Reflect . getMetadata === "function" && Reflect . getMetadata !== getMetadata ) {
622
623
return Reflect . getMetadata ( metadataKey , target , propertyKey ! ) ;
623
624
}
624
625
if ( ! IsObject ( target ) ) throw new TypeError ( ) ;
@@ -712,7 +713,7 @@ export function getOwnMetadata(metadataKey: any, target: any, propertyKey: strin
712
713
*
713
714
*/
714
715
export function getOwnMetadata ( metadataKey : any , target : any , propertyKey ?: string | symbol ) : any {
715
- if ( typeof Reflect !== "undefined" && typeof Reflect . getOwnMetadata === "function" && Reflect . getOwnMetadata !== getOwnMetadata ) {
716
+ if ( ! hasSetMetadata && typeof Reflect !== "undefined" && typeof Reflect . getOwnMetadata === "function" && Reflect . getOwnMetadata !== getOwnMetadata ) {
716
717
return Reflect . getOwnMetadata ( metadataKey , target , propertyKey ! ) ;
717
718
}
718
719
if ( ! IsObject ( target ) ) throw new TypeError ( ) ;
@@ -803,7 +804,7 @@ export function getMetadataKeys(target: any, propertyKey: string | symbol): any[
803
804
*
804
805
*/
805
806
export function getMetadataKeys ( target : any , propertyKey ?: string | symbol ) : any [ ] {
806
- if ( typeof Reflect !== "undefined" && typeof Reflect . getMetadataKeys === "function" && Reflect . getMetadataKeys !== getMetadataKeys ) {
807
+ if ( ! hasSetMetadata && typeof Reflect !== "undefined" && typeof Reflect . getMetadataKeys === "function" && Reflect . getMetadataKeys !== getMetadataKeys ) {
807
808
return Reflect . getMetadataKeys ( target , propertyKey ! ) ;
808
809
}
809
810
if ( ! IsObject ( target ) ) throw new TypeError ( ) ;
@@ -894,7 +895,7 @@ export function getOwnMetadataKeys(target: any, propertyKey: string | symbol): a
894
895
*
895
896
*/
896
897
export function getOwnMetadataKeys ( target : any , propertyKey ?: string | symbol ) : any [ ] {
897
- if ( typeof Reflect !== "undefined" && typeof Reflect . getOwnMetadataKeys === "function" && Reflect . getOwnMetadataKeys !== getOwnMetadataKeys ) {
898
+ if ( ! hasSetMetadata && typeof Reflect !== "undefined" && typeof Reflect . getOwnMetadataKeys === "function" && Reflect . getOwnMetadataKeys !== getOwnMetadataKeys ) {
898
899
return Reflect . getOwnMetadataKeys ( target , propertyKey ! ) ;
899
900
}
900
901
if ( ! IsObject ( target ) ) throw new TypeError ( ) ;
@@ -988,7 +989,7 @@ export function deleteMetadata(metadataKey: any, target: any, propertyKey: strin
988
989
*
989
990
*/
990
991
export function deleteMetadata ( metadataKey : any , target : any , propertyKey ?: string | symbol ) : boolean {
991
- if ( typeof Reflect !== "undefined" && typeof Reflect . deleteMetadata === "function" && Reflect . deleteMetadata !== deleteMetadata ) {
992
+ if ( ! hasSetMetadata && typeof Reflect !== "undefined" && typeof Reflect . deleteMetadata === "function" && Reflect . deleteMetadata !== deleteMetadata ) {
992
993
return Reflect . deleteMetadata ( metadataKey , target , propertyKey ! ) ;
993
994
}
994
995
if ( ! IsObject ( target ) ) throw new TypeError ( ) ;
@@ -1038,6 +1039,7 @@ function GetOrCreateMetadataMap(O: any, P: string | symbol | undefined, Create:
1038
1039
if ( ! Create ) return undefined ;
1039
1040
targetMetadata = new _Map < string | symbol | undefined , Map < any , any > > ( ) ;
1040
1041
Metadata . set ( O , targetMetadata ) ;
1042
+ hasSetMetadata = true ;
1041
1043
}
1042
1044
let metadataMap = targetMetadata . get ( P ) ;
1043
1045
if ( IsUndefined ( metadataMap ) ) {
0 commit comments