refactor(compiler): introduce directive wrappers to generate less code
- for now only wraps the `@Input` properties and calls to `ngOnInit`, `ngDoCheck` and `ngOnChanges` of directives. - also groups eval sources by NgModule. Part of #11683
This commit is contained in:

committed by
Alex Rickabaugh

parent
c951822c35
commit
b0a03fcab3
@ -64,11 +64,6 @@ export var __core_private__: {
|
||||
_NgModuleInjector?: ng_module_factory.NgModuleInjector<any>,
|
||||
registerModuleFactory: typeof ng_module_factory_loader.registerModuleFactory,
|
||||
ViewType: typeof view_type.ViewType, _ViewType?: view_type.ViewType,
|
||||
MAX_INTERPOLATION_VALUES: typeof view_utils.MAX_INTERPOLATION_VALUES,
|
||||
checkBinding: typeof view_utils.checkBinding,
|
||||
flattenNestedViewRenderNodes: typeof view_utils.flattenNestedViewRenderNodes,
|
||||
interpolate: typeof view_utils.interpolate,
|
||||
ViewUtils: typeof view_utils.ViewUtils, _ViewUtils?: view_utils.ViewUtils,
|
||||
ViewMetadata: typeof metadata_view.ViewMetadata, _ViewMetadata?: metadata_view.ViewMetadata,
|
||||
DebugContext: typeof debug_context.DebugContext, _DebugContext?: debug_context.DebugContext,
|
||||
StaticNodeDebugInfo: typeof debug_context.StaticNodeDebugInfo,
|
||||
@ -84,19 +79,6 @@ export var __core_private__: {
|
||||
makeDecorator: typeof decorators.makeDecorator,
|
||||
DebugDomRootRenderer: typeof debug.DebugDomRootRenderer,
|
||||
_DebugDomRootRenderer?: debug.DebugDomRootRenderer,
|
||||
EMPTY_ARRAY: typeof view_utils.EMPTY_ARRAY,
|
||||
EMPTY_MAP: typeof view_utils.EMPTY_MAP,
|
||||
pureProxy1: typeof view_utils.pureProxy1,
|
||||
pureProxy2: typeof view_utils.pureProxy2,
|
||||
pureProxy3: typeof view_utils.pureProxy3,
|
||||
pureProxy4: typeof view_utils.pureProxy4,
|
||||
pureProxy5: typeof view_utils.pureProxy5,
|
||||
pureProxy6: typeof view_utils.pureProxy6,
|
||||
pureProxy7: typeof view_utils.pureProxy7,
|
||||
pureProxy8: typeof view_utils.pureProxy8,
|
||||
pureProxy9: typeof view_utils.pureProxy9,
|
||||
pureProxy10: typeof view_utils.pureProxy10,
|
||||
castByValue: typeof view_utils.castByValue,
|
||||
Console: typeof console.Console, _Console?: console.Console,
|
||||
reflector: typeof reflection.reflector,
|
||||
Reflector: typeof reflection.Reflector, _Reflector?: reflection.Reflector,
|
||||
@ -121,6 +103,7 @@ export var __core_private__: {
|
||||
ComponentStillLoadingError: typeof ComponentStillLoadingError,
|
||||
isPromise: typeof isPromise,
|
||||
AnimationTransition: typeof AnimationTransition
|
||||
view_utils: typeof view_utils,
|
||||
} = {
|
||||
isDefaultChangeDetectionStrategy: constants.isDefaultChangeDetectionStrategy,
|
||||
ChangeDetectorStatus: constants.ChangeDetectorStatus,
|
||||
@ -135,11 +118,7 @@ export var __core_private__: {
|
||||
NgModuleInjector: ng_module_factory.NgModuleInjector,
|
||||
registerModuleFactory: ng_module_factory_loader.registerModuleFactory,
|
||||
ViewType: view_type.ViewType,
|
||||
MAX_INTERPOLATION_VALUES: view_utils.MAX_INTERPOLATION_VALUES,
|
||||
checkBinding: view_utils.checkBinding,
|
||||
flattenNestedViewRenderNodes: view_utils.flattenNestedViewRenderNodes,
|
||||
interpolate: view_utils.interpolate,
|
||||
ViewUtils: view_utils.ViewUtils,
|
||||
view_utils: view_utils,
|
||||
ViewMetadata: metadata_view.ViewMetadata,
|
||||
DebugContext: debug_context.DebugContext,
|
||||
StaticNodeDebugInfo: debug_context.StaticNodeDebugInfo,
|
||||
@ -151,19 +130,6 @@ export var __core_private__: {
|
||||
ReflectionCapabilities: reflection_capabilities.ReflectionCapabilities,
|
||||
makeDecorator: decorators.makeDecorator,
|
||||
DebugDomRootRenderer: debug.DebugDomRootRenderer,
|
||||
EMPTY_ARRAY: view_utils.EMPTY_ARRAY,
|
||||
EMPTY_MAP: view_utils.EMPTY_MAP,
|
||||
pureProxy1: view_utils.pureProxy1,
|
||||
pureProxy2: view_utils.pureProxy2,
|
||||
pureProxy3: view_utils.pureProxy3,
|
||||
pureProxy4: view_utils.pureProxy4,
|
||||
pureProxy5: view_utils.pureProxy5,
|
||||
pureProxy6: view_utils.pureProxy6,
|
||||
pureProxy7: view_utils.pureProxy7,
|
||||
pureProxy8: view_utils.pureProxy8,
|
||||
pureProxy9: view_utils.pureProxy9,
|
||||
pureProxy10: view_utils.pureProxy10,
|
||||
castByValue: view_utils.castByValue,
|
||||
Console: console.Console,
|
||||
reflector: reflection.reflector,
|
||||
Reflector: reflection.Reflector,
|
||||
|
@ -7,13 +7,14 @@
|
||||
*/
|
||||
|
||||
import {APP_ID} from '../application_tokens';
|
||||
import {devModeEqual} from '../change_detection/change_detection';
|
||||
import {SimpleChange, devModeEqual} from '../change_detection/change_detection';
|
||||
import {UNINITIALIZED} from '../change_detection/change_detection_util';
|
||||
import {Inject, Injectable} from '../di';
|
||||
import {isPresent, looseIdentical} from '../facade/lang';
|
||||
import {ViewEncapsulation} from '../metadata/view';
|
||||
import {RenderComponentType, Renderer, RootRenderer} from '../render/api';
|
||||
import {Sanitizer} from '../security';
|
||||
|
||||
import {AppElement} from './element';
|
||||
import {ExpressionChangedAfterItHasBeenCheckedError} from './errors';
|
||||
|
||||
@ -352,3 +353,27 @@ export function pureProxy10<P0, P1, P2, P3, P4, P5, P6, P7, P8, P9, R>(
|
||||
return result;
|
||||
};
|
||||
}
|
||||
|
||||
export function setBindingDebugInfoForChanges(
|
||||
renderer: Renderer, el: any, changes: {[key: string]: SimpleChange}) {
|
||||
Object.keys(changes).forEach((propName) => {
|
||||
setBindingDebugInfo(renderer, el, propName, changes[propName].currentValue);
|
||||
});
|
||||
}
|
||||
|
||||
export function setBindingDebugInfo(renderer: Renderer, el: any, propName: string, value: any) {
|
||||
try {
|
||||
renderer.setBindingDebugInfo(
|
||||
el, `ng-reflect-${camelCaseToDashCase(propName)}`, value ? value.toString() : null);
|
||||
} catch (e) {
|
||||
renderer.setBindingDebugInfo(
|
||||
el, `ng-reflect-${camelCaseToDashCase(propName)}`,
|
||||
'[ERROR] Exception while trying to serialize the value');
|
||||
}
|
||||
}
|
||||
|
||||
const CAMEL_CASE_REGEXP = /([A-Z])/g;
|
||||
|
||||
function camelCaseToDashCase(input: string): string {
|
||||
return input.replace(CAMEL_CASE_REGEXP, (...m: any[]) => '-' + m[1].toLowerCase());
|
||||
}
|
||||
|
Reference in New Issue
Block a user