refactor(core): rename ngPipeDef to ɵpipe (#33142)
Pipe defs are not considered public API, so the property that contains them should be prefixed with Angular's marker for "private" ('ɵ') to discourage apps from relying on def APIs directly. This commit adds the prefix and shortens the name from ngPipeDef to pipe. This is because property names cannot be minified by Uglify without turning on property mangling (which most apps have turned off) and are thus size-sensitive. PR Close #33142
This commit is contained in:

committed by
Miško Hevery

parent
f433d6604b
commit
d62eff7316
@ -241,7 +241,7 @@ ivyEnabled && describe('render3 jit', () => {
|
||||
class P {
|
||||
}
|
||||
|
||||
const pipeDef = (P as any).ngPipeDef as PipeDef<P>;
|
||||
const pipeDef = (P as any).ɵpipe as PipeDef<P>;
|
||||
const pipeFactory = (P as any).ɵfac as FactoryFn<P>;
|
||||
expect(pipeDef.name).toBe('test-pipe');
|
||||
expect(pipeDef.pure).toBe(false, 'pipe should not be pure');
|
||||
@ -254,7 +254,7 @@ ivyEnabled && describe('render3 jit', () => {
|
||||
class P {
|
||||
}
|
||||
|
||||
const pipeDef = (P as any).ngPipeDef as PipeDef<P>;
|
||||
const pipeDef = (P as any).ɵpipe as PipeDef<P>;
|
||||
expect(pipeDef.pure).toBe(true, 'pipe should be pure');
|
||||
});
|
||||
|
||||
|
@ -30,7 +30,7 @@ describe('pipe', () => {
|
||||
transform(value: any) { return new WrappedValue('Bar'); }
|
||||
|
||||
static ɵfac = function WrappingPipe_Factory() { return new WrappingPipe(); };
|
||||
static ngPipeDef = ɵɵdefinePipe({name: 'wrappingPipe', type: WrappingPipe, pure: false});
|
||||
static ɵpipe = ɵɵdefinePipe({name: 'wrappingPipe', type: WrappingPipe, pure: false});
|
||||
}
|
||||
|
||||
function createTemplate() {
|
||||
|
@ -21,12 +21,12 @@ declare class SubComponent extends SuperComponent {
|
||||
static ɵcmp: ɵɵComponentDefWithMeta<SubComponent, '[sub]', never, {}, {}, never>;
|
||||
}
|
||||
|
||||
declare class SuperPipe { static ngPipeDef: PipeDefWithMeta<SuperPipe, 'super'>; }
|
||||
declare class SuperPipe { static ɵpipe: PipeDefWithMeta<SuperPipe, 'super'>; }
|
||||
|
||||
declare class SubPipe extends SuperPipe {
|
||||
onlyInSubtype: string;
|
||||
|
||||
static ngPipeDef: PipeDefWithMeta<SubPipe, 'sub'>;
|
||||
static ɵpipe: PipeDefWithMeta<SubPipe, 'sub'>;
|
||||
}
|
||||
|
||||
describe('inheritance strict type checking', () => {
|
||||
|
@ -660,20 +660,20 @@ describe('TestBed', () => {
|
||||
expect(DirectiveWithNoAnnotations.hasOwnProperty('ɵdir')).toBeTruthy();
|
||||
expect(SomeDirective.hasOwnProperty('ɵdir')).toBeTruthy();
|
||||
|
||||
expect(PipeWithNoAnnotations.hasOwnProperty('ngPipeDef')).toBeTruthy();
|
||||
expect(SomePipe.hasOwnProperty('ngPipeDef')).toBeTruthy();
|
||||
expect(PipeWithNoAnnotations.hasOwnProperty('ɵpipe')).toBeTruthy();
|
||||
expect(SomePipe.hasOwnProperty('ɵpipe')).toBeTruthy();
|
||||
|
||||
TestBed.resetTestingModule();
|
||||
|
||||
// ng defs should be removed from classes with no annotations
|
||||
expect(ComponentWithNoAnnotations.hasOwnProperty('ɵcmp')).toBeFalsy();
|
||||
expect(DirectiveWithNoAnnotations.hasOwnProperty('ɵdir')).toBeFalsy();
|
||||
expect(PipeWithNoAnnotations.hasOwnProperty('ngPipeDef')).toBeFalsy();
|
||||
expect(PipeWithNoAnnotations.hasOwnProperty('ɵpipe')).toBeFalsy();
|
||||
|
||||
// ng defs should be preserved on super types
|
||||
expect(SomeComponent.hasOwnProperty('ɵcmp')).toBeTruthy();
|
||||
expect(SomeDirective.hasOwnProperty('ɵdir')).toBeTruthy();
|
||||
expect(SomePipe.hasOwnProperty('ngPipeDef')).toBeTruthy();
|
||||
expect(SomePipe.hasOwnProperty('ɵpipe')).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should clean up overridden providers for modules that are imported more than once',
|
||||
|
Reference in New Issue
Block a user