Skip to content

Use ReflectorReader to get inputs (fixes #3007) #3008

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 22, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down
7 changes: 3 additions & 4 deletions src/ng2/directives/uiView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -27,12 +28,10 @@ interface InputMapping {
prop: string;
}

declare var Reflect: any;

/** @hidden */
const ng2ComponentInputs = (ng2CompClass: Type<any>) => {
/** 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] }))
Expand All @@ -44,7 +43,7 @@ const ng2ComponentInputs = (ng2CompClass: Type<any>) => {
.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
Expand Down
3 changes: 3 additions & 0 deletions src/ng2/private_import_core.ts
Original file line number Diff line number Diff line change
@@ -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;