fix(ivy): use default selector for Components if selector is empty (#29239)

Prior to this change default selector for Components was not applied in case selector is missing or defined as an empty string. This update aligns this behavior between Ivy and VE: now default selector is used for Components when it's needed. Directives with empty selector are not allowed and trigger a compile-time error in both Ivy and VE.

PR Close #29239
This commit is contained in:
Andrew Kushnir
2019-03-11 17:58:37 -07:00
committed by Kara Erickson
parent 9d4b7d7d41
commit fe76494759
3 changed files with 85 additions and 1 deletions

View File

@ -172,7 +172,8 @@ export function extractDirectiveMetadata(
throw new FatalDiagnosticError(
ErrorCode.VALUE_HAS_WRONG_TYPE, expr, `selector must be a string`);
}
selector = resolved;
// use default selector in case selector is an empty string
selector = resolved === '' ? defaultSelector : resolved;
}
if (!selector) {
throw new Error(`Directive ${clazz.name !.text} has no selector, please add it!`);