fix(core): make decorators closure safe (#16905)
This is required as e.g. `token` from `@Inject` is accessed in string form via makeParamDecorator but as a property in the `ReflectiveInjector`. Closes #16889 as this is a more general fix.
This commit is contained in:

committed by
Chuck Jazdzewski

parent
5af143e8e4
commit
a80ac0a8d3
@ -119,7 +119,7 @@ export interface Attribute { attributeName?: string; }
|
||||
* @Annotation
|
||||
*/
|
||||
export const Attribute: AttributeDecorator =
|
||||
makeParamDecorator('Attribute', [['attributeName', undefined]]);
|
||||
makeParamDecorator('Attribute', (attributeName?: string) => ({attributeName}));
|
||||
|
||||
/**
|
||||
* Type of the Query metadata.
|
||||
@ -207,14 +207,8 @@ export type ContentChildren = Query;
|
||||
export const ContentChildren: ContentChildrenDecorator =
|
||||
<ContentChildrenDecorator>makePropDecorator(
|
||||
'ContentChildren',
|
||||
[
|
||||
['selector', undefined], {
|
||||
first: false,
|
||||
isViewQuery: false,
|
||||
descendants: false,
|
||||
read: undefined,
|
||||
}
|
||||
],
|
||||
(selector?: any, data: any = {}) =>
|
||||
({selector, first: false, isViewQuery: false, descendants: false, ...data}),
|
||||
Query);
|
||||
|
||||
/**
|
||||
@ -273,15 +267,8 @@ export type ContentChild = Query;
|
||||
* @Annotation
|
||||
*/
|
||||
export const ContentChild: ContentChildDecorator = makePropDecorator(
|
||||
'ContentChild',
|
||||
[
|
||||
['selector', undefined], {
|
||||
first: true,
|
||||
isViewQuery: false,
|
||||
descendants: true,
|
||||
read: undefined,
|
||||
}
|
||||
],
|
||||
'ContentChild', (selector?: any, data: any = {}) =>
|
||||
({selector, first: true, isViewQuery: false, descendants: true, ...data}),
|
||||
Query);
|
||||
|
||||
/**
|
||||
@ -339,15 +326,8 @@ export type ViewChildren = Query;
|
||||
* @Annotation
|
||||
*/
|
||||
export const ViewChildren: ViewChildrenDecorator = makePropDecorator(
|
||||
'ViewChildren',
|
||||
[
|
||||
['selector', undefined], {
|
||||
first: false,
|
||||
isViewQuery: true,
|
||||
descendants: true,
|
||||
read: undefined,
|
||||
}
|
||||
],
|
||||
'ViewChildren', (selector?: any, data: any = {}) =>
|
||||
({selector, first: false, isViewQuery: true, descendants: true, ...data}),
|
||||
Query);
|
||||
|
||||
/**
|
||||
@ -403,13 +383,6 @@ export type ViewChild = Query;
|
||||
* @Annotation
|
||||
*/
|
||||
export const ViewChild: ViewChildDecorator = makePropDecorator(
|
||||
'ViewChild',
|
||||
[
|
||||
['selector', undefined], {
|
||||
first: true,
|
||||
isViewQuery: true,
|
||||
descendants: true,
|
||||
read: undefined,
|
||||
}
|
||||
],
|
||||
'ViewChild', (selector: any, data: any) =>
|
||||
({selector, first: true, isViewQuery: true, descendants: true, ...data}),
|
||||
Query);
|
||||
|
@ -399,15 +399,8 @@ export interface Directive {
|
||||
* @stable
|
||||
* @Annotation
|
||||
*/
|
||||
export const Directive: DirectiveDecorator = <DirectiveDecorator>makeDecorator('Directive', {
|
||||
selector: undefined,
|
||||
inputs: undefined,
|
||||
outputs: undefined,
|
||||
host: undefined,
|
||||
providers: undefined,
|
||||
exportAs: undefined,
|
||||
queries: undefined
|
||||
});
|
||||
export const Directive: DirectiveDecorator =
|
||||
<DirectiveDecorator>makeDecorator('Directive', (dir: Directive = {}) => dir);
|
||||
|
||||
/**
|
||||
* Type of the Component decorator / constructor function.
|
||||
@ -691,26 +684,7 @@ export interface Component extends Directive {
|
||||
* @Annotation
|
||||
*/
|
||||
export const Component: ComponentDecorator = <ComponentDecorator>makeDecorator(
|
||||
'Component', {
|
||||
selector: undefined,
|
||||
inputs: undefined,
|
||||
outputs: undefined,
|
||||
host: undefined,
|
||||
exportAs: undefined,
|
||||
moduleId: undefined,
|
||||
providers: undefined,
|
||||
viewProviders: undefined,
|
||||
changeDetection: ChangeDetectionStrategy.Default,
|
||||
queries: undefined,
|
||||
templateUrl: undefined,
|
||||
template: undefined,
|
||||
styleUrls: undefined,
|
||||
styles: undefined,
|
||||
animations: undefined,
|
||||
encapsulation: undefined,
|
||||
interpolation: undefined,
|
||||
entryComponents: undefined
|
||||
},
|
||||
'Component', (c: Component = {}) => ({changeDetection: ChangeDetectionStrategy.Default, ...c}),
|
||||
Directive);
|
||||
|
||||
/**
|
||||
@ -750,10 +724,8 @@ export interface Pipe {
|
||||
* @stable
|
||||
* @Annotation
|
||||
*/
|
||||
export const Pipe: PipeDecorator = <PipeDecorator>makeDecorator('Pipe', {
|
||||
name: undefined,
|
||||
pure: true,
|
||||
});
|
||||
export const Pipe: PipeDecorator =
|
||||
<PipeDecorator>makeDecorator('Pipe', (p: Pipe) => ({pure: true, ...p}));
|
||||
|
||||
|
||||
/**
|
||||
@ -825,7 +797,7 @@ export interface Input {
|
||||
* @Annotation
|
||||
*/
|
||||
export const Input: InputDecorator =
|
||||
makePropDecorator('Input', [['bindingPropertyName', undefined]]);
|
||||
makePropDecorator('Input', (bindingPropertyName?: string) => ({bindingPropertyName}));
|
||||
|
||||
/**
|
||||
* Type of the Output decorator / constructor function.
|
||||
@ -891,7 +863,7 @@ export interface Output { bindingPropertyName?: string; }
|
||||
* @Annotation
|
||||
*/
|
||||
export const Output: OutputDecorator =
|
||||
makePropDecorator('Output', [['bindingPropertyName', undefined]]);
|
||||
makePropDecorator('Output', (bindingPropertyName?: string) => ({bindingPropertyName}));
|
||||
|
||||
|
||||
/**
|
||||
@ -951,7 +923,7 @@ export interface HostBinding { hostPropertyName?: string; }
|
||||
* @Annotation
|
||||
*/
|
||||
export const HostBinding: HostBindingDecorator =
|
||||
makePropDecorator('HostBinding', [['hostPropertyName', undefined]]);
|
||||
makePropDecorator('HostBinding', (hostPropertyName?: string) => ({hostPropertyName}));
|
||||
|
||||
|
||||
/**
|
||||
@ -1013,4 +985,4 @@ export interface HostListener {
|
||||
* @Annotation
|
||||
*/
|
||||
export const HostListener: HostListenerDecorator =
|
||||
makePropDecorator('HostListener', [['eventName', undefined], ['args', []]]);
|
||||
makePropDecorator('HostListener', (eventName?: string, args?: string[]) => ({eventName, args}));
|
||||
|
@ -190,13 +190,5 @@ export interface NgModule {
|
||||
* @stable
|
||||
* @Annotation
|
||||
*/
|
||||
export const NgModule: NgModuleDecorator = <NgModuleDecorator>makeDecorator('NgModule', {
|
||||
providers: undefined,
|
||||
declarations: undefined,
|
||||
imports: undefined,
|
||||
exports: undefined,
|
||||
entryComponents: undefined,
|
||||
bootstrap: undefined,
|
||||
schemas: undefined,
|
||||
id: undefined,
|
||||
});
|
||||
export const NgModule: NgModuleDecorator =
|
||||
<NgModuleDecorator>makeDecorator('NgModule', (ngModule: NgModule) => ngModule);
|
Reference in New Issue
Block a user