refactor(ivy): move directive into elementStart (#21374)
We used to have a separate `directive` instruction for instantiating directives. However, such an instruction requires that directives are created in the correct order, which would require that template compiler would have knowledge of all dependent directives. This would break template compilation locality principle. This change only changes the APIs to expected form but does not change the semantics. The semantics will need to be corrected in subsequent commits. The semantic change needed is to resolve the directive instantiation error at runtime based on injection dependencies. PR Close #21374
This commit is contained in:
@ -7,6 +7,7 @@
|
||||
*/
|
||||
|
||||
import {stringifyElement} from '@angular/platform-browser/testing/src/browser_util';
|
||||
import {DirectiveDefArgs} from '../../src/render3/definition_interfaces';
|
||||
import {ComponentTemplate, ComponentType, DirectiveType, PublicFeature, defineComponent, defineDirective, renderComponent as _renderComponent} from '../../src/render3/index';
|
||||
import {NG_HOST_SYMBOL, createLNode, createLView, renderTemplate} from '../../src/render3/instructions';
|
||||
import {LElementNode, LNodeFlags} from '../../src/render3/interfaces/node';
|
||||
@ -89,12 +90,13 @@ export function createComponent(
|
||||
};
|
||||
}
|
||||
|
||||
export function createDirective(): DirectiveType<any> {
|
||||
export function createDirective({exportAs}: {exportAs?: string} = {}): DirectiveType<any> {
|
||||
return class Directive {
|
||||
static ngDirectiveDef = defineDirective({
|
||||
type: Directive,
|
||||
factory: () => new Directive(),
|
||||
features: [PublicFeature],
|
||||
exportAs: exportAs,
|
||||
});
|
||||
};
|
||||
}
|
||||
|
Reference in New Issue
Block a user