refactor(ivy): remove pipe references from the template (#23032)
PR Close #23032
This commit is contained in:

committed by
Alex Rickabaugh

parent
5a86f7144f
commit
e2e80ec61c
@ -16,7 +16,7 @@ import {Type} from '../type';
|
||||
import {resolveRendererType2} from '../view/util';
|
||||
|
||||
import {diPublic} from './di';
|
||||
import {ComponentDef, ComponentDefFeature, ComponentTemplate, DirectiveDef, DirectiveDefFeature, DirectiveDefListOrFactory, PipeDef} from './interfaces/definition';
|
||||
import {ComponentDef, ComponentDefFeature, ComponentTemplate, DirectiveDef, DirectiveDefFeature, DirectiveDefListOrFactory, PipeDef, PipeDefListOrFactory} from './interfaces/definition';
|
||||
import {CssSelector} from './interfaces/projection';
|
||||
|
||||
|
||||
@ -154,6 +154,14 @@ export function defineComponent<T>(componentDefinition: {
|
||||
* `DirectiveDef`s. The function is necessary to be able to support forward declarations.
|
||||
*/
|
||||
directiveDefs?: DirectiveDefListOrFactory | null;
|
||||
|
||||
/**
|
||||
* Registry of pipes that may be found in this component's view.
|
||||
*
|
||||
* The property is either an array of `PipeDefs`s or a function which returns the array of
|
||||
* `PipeDefs`s. The function is necessary to be able to support forward declarations.
|
||||
*/
|
||||
pipeDefs?: PipeDefListOrFactory | null;
|
||||
}): ComponentDef<T> {
|
||||
const type = componentDefinition.type;
|
||||
const def = <ComponentDef<any>>{
|
||||
@ -176,6 +184,7 @@ export function defineComponent<T>(componentDefinition: {
|
||||
onDestroy: type.prototype.ngOnDestroy || null,
|
||||
onPush: componentDefinition.changeDetection === ChangeDetectionStrategy.OnPush,
|
||||
directiveDefs: componentDefinition.directiveDefs || null,
|
||||
pipeDefs: componentDefinition.pipeDefs || null,
|
||||
selector: componentDefinition.selector
|
||||
};
|
||||
const feature = componentDefinition.features;
|
||||
@ -380,15 +389,25 @@ export const defineDirective = defineComponent as any as<T>(directiveDefinition:
|
||||
* });
|
||||
* }
|
||||
* ```
|
||||
* @param type Pipe class reference. Needed to extract pipe lifecycle hooks.
|
||||
* @param factory A factory for creating a pipe instance.
|
||||
* @param pure Whether the pipe is pure.
|
||||
* @param pipeDef Pipe definition generated by the compiler
|
||||
*/
|
||||
export function definePipe<T>(
|
||||
{type, factory, pure}: {type: Type<T>, factory: () => T, pure?: boolean}): PipeDef<T> {
|
||||
export function definePipe<T>(pipeDef: {
|
||||
/** Name of the pipe. Used for matching pipes in template to pipe defs. */
|
||||
name: string,
|
||||
|
||||
/** Pipe class reference. Needed to extract pipe lifecycle hooks. */
|
||||
type: Type<T>,
|
||||
|
||||
/** A factory for creating a pipe instance. */
|
||||
factory: () => T,
|
||||
|
||||
/** Whether the pipe is pure. */
|
||||
pure?: boolean
|
||||
}): PipeDef<T> {
|
||||
return <PipeDef<T>>{
|
||||
n: factory,
|
||||
pure: pure !== false,
|
||||
onDestroy: type.prototype.ngOnDestroy || null
|
||||
name: pipeDef.name,
|
||||
n: pipeDef.factory,
|
||||
pure: pipeDef.pure !== false,
|
||||
onDestroy: pipeDef.type.prototype.ngOnDestroy || null
|
||||
};
|
||||
}
|
||||
|
Reference in New Issue
Block a user