fix(ivy): support multiple exportAs (#27996)
Allows for multiple, comma-separated `exportAs` names, similarly to `ViewEngine`. These changes fix FW-708. PR Close #27996
This commit is contained in:

committed by
Andrew Kushnir

parent
b78351cc7e
commit
9277142d54
@ -151,7 +151,7 @@ export function defineComponent<T>(componentDefinition: {
|
||||
*
|
||||
* See: {@link Directive.exportAs}
|
||||
*/
|
||||
exportAs?: string;
|
||||
exportAs?: string[];
|
||||
|
||||
/**
|
||||
* Template function use for rendering DOM.
|
||||
@ -605,7 +605,7 @@ export const defineDirective = defineComponent as any as<T>(directiveDefinition:
|
||||
*
|
||||
* See: {@link Directive.exportAs}
|
||||
*/
|
||||
exportAs?: string;
|
||||
exportAs?: string[];
|
||||
}) => never;
|
||||
|
||||
/**
|
||||
|
@ -1716,7 +1716,11 @@ function saveNameToExportMap(
|
||||
index: number, def: DirectiveDef<any>| ComponentDef<any>,
|
||||
exportsMap: {[key: string]: number} | null) {
|
||||
if (exportsMap) {
|
||||
if (def.exportAs) exportsMap[def.exportAs] = index;
|
||||
if (def.exportAs) {
|
||||
for (let i = 0; i < def.exportAs.length; i++) {
|
||||
exportsMap[def.exportAs[i]] = index;
|
||||
}
|
||||
}
|
||||
if ((def as ComponentDef<any>).template) exportsMap[''] = index;
|
||||
}
|
||||
}
|
||||
|
@ -121,7 +121,7 @@ export interface DirectiveDef<T> extends BaseDef<T> {
|
||||
/**
|
||||
* Name under which the directive is exported (for use with local references in template)
|
||||
*/
|
||||
readonly exportAs: string|null;
|
||||
readonly exportAs: string[]|null;
|
||||
|
||||
/**
|
||||
* Factory function used to create a new directive instance.
|
||||
@ -349,4 +349,4 @@ export type PipeTypeList =
|
||||
|
||||
// Note: This hack is necessary so we don't erroneously get a circular dependency
|
||||
// failure based on types.
|
||||
export const unusedValueExportToPlacateAjd = 1;
|
||||
export const unusedValueExportToPlacateAjd = 1;
|
||||
|
Reference in New Issue
Block a user