From e090fde5225053a7877f85e939df01983a7a044e Mon Sep 17 00:00:00 2001 From: Valentin Funk Date: Fri, 16 Sep 2016 22:58:34 +0200 Subject: [PATCH] Use ReflectorReader to get inputs (fixes #3007) --- package.json | 11 +++++------ src/ng2/directives/uiView.ts | 7 +++---- src/ng2/private_import_core.ts | 3 +++ 3 files changed, 11 insertions(+), 10 deletions(-) create mode 100644 src/ng2/private_import_core.ts diff --git a/package.json b/package.json index 411e7bed1..6484e5976 100644 --- a/package.json +++ b/package.json @@ -56,11 +56,11 @@ }, "license": "MIT", "devDependencies": { - "@angular/common": "^2.0.0-rc.7", - "@angular/compiler": "^2.0.0-rc.7", - "@angular/core": "^2.0.0-rc.7", - "@angular/platform-browser": "^2.0.0-rc.7", - "@angular/platform-browser-dynamic": "^2.0.0-rc.7", + "@angular/common": "^2.0.0", + "@angular/compiler": "^2.0.0", + "@angular/core": "^2.0.0", + "@angular/platform-browser": "^2.0.0", + "@angular/platform-browser-dynamic": "^2.0.0", "babel-core": "^5.8.14", "clone": "^1.0.2", "conventional-changelog": "^1.1.0", @@ -80,7 +80,6 @@ "lodash": "^4.5.1", "parallelshell": "^2.0.0", "phantomjs-polyfill": "0.0.1", - "reflect-metadata": "=0.1.2", "remap-istanbul": "^0.6.3", "rxjs": "5.0.0-beta.12", "shelljs": "^0.7.0", diff --git a/src/ng2/directives/uiView.ts b/src/ng2/directives/uiView.ts index 0fc55998f..d45ca613d 100755 --- a/src/ng2/directives/uiView.ts +++ b/src/ng2/directives/uiView.ts @@ -3,6 +3,7 @@ import { Component, ComponentFactoryResolver, ViewContainerRef, Input, ComponentRef, Type, ReflectiveInjector, ViewChild, Injector, Inject } from '@angular/core'; +import {ReflectorReader, reflector} from '../private_import_core'; import {UIRouter} from "../../router"; import {trace} from "../../common/trace"; @@ -27,12 +28,10 @@ interface InputMapping { prop: string; } -declare var Reflect: any; - /** @hidden */ const ng2ComponentInputs = (ng2CompClass: Type) => { /** Get "@Input('foo') _foo" inputs */ - let props = Reflect['getMetadata']('propMetadata', ng2CompClass); + let props = reflector.propMetadata(ng2CompClass); let _props = Object.keys(props || {}) // -> [ { key: string, anno: annotations[] } ] tuples .map(key => ({ key, annoArr: props[key] })) @@ -44,7 +43,7 @@ const ng2ComponentInputs = (ng2CompClass: Type) => { .map(tuple => ({ token: tuple.anno.bindingPropertyName || tuple.key, prop: tuple.key })); /** Get "inputs: ['foo']" inputs */ - let inputs = Reflect['getMetadata']('annotations', ng2CompClass) + let inputs = reflector.annotations(ng2CompClass) // Find the ComponentMetadata class annotation .filter(x => x instanceof Component && !!x.inputs) // Get the .inputs string array diff --git a/src/ng2/private_import_core.ts b/src/ng2/private_import_core.ts new file mode 100644 index 000000000..beac02b3a --- /dev/null +++ b/src/ng2/private_import_core.ts @@ -0,0 +1,3 @@ +import { __core_private__ as r} from '@angular/core'; +export type ReflectorReader = typeof r._ReflectorReader; +export var reflector: typeof r.reflector = r.reflector; \ No newline at end of file