Skip to content

Commit

Permalink
fix: check reflectionIsSupported in decorator runtime (#350)
Browse files Browse the repository at this point in the history
* check reflectionIsSupported in decorator runtime

* fix lint
  • Loading branch information
vitalishapovalov authored and ktsn committed Nov 11, 2019
1 parent f25f35b commit 2fc6ab5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/component.ts
Expand Up @@ -83,7 +83,7 @@ export function componentFactory (

forwardStaticMembers(Extended, Component, Super)

if (reflectionIsSupported) {
if (reflectionIsSupported()) {
copyReflectionMetadata(Extended, Component)
}

Expand Down
4 changes: 3 additions & 1 deletion src/reflect.ts
Expand Up @@ -4,7 +4,9 @@ import { VueClass } from './declarations'
// The rational behind the verbose Reflect-feature check below is the fact that there are polyfills
// which add an implementation for Reflect.defineMetadata but not for Reflect.getOwnMetadataKeys.
// Without this check consumers will encounter hard to track down runtime errors.
export const reflectionIsSupported = typeof Reflect !== 'undefined' && Reflect.defineMetadata && Reflect.getOwnMetadataKeys
export function reflectionIsSupported () {
return typeof Reflect !== 'undefined' && Reflect.defineMetadata && Reflect.getOwnMetadataKeys
}

export function copyReflectionMetadata (
to: VueConstructor,
Expand Down

0 comments on commit 2fc6ab5

Please sign in to comment.