fix(compiler): allow single quotes into named interpolations (#15461)

Fixes #15318
This commit is contained in:
Olivier Combe 2017-03-24 23:10:41 +01:00 committed by Victor Berchet
parent c17b912eb9
commit 53b89ec312
2 changed files with 9 additions and 2 deletions

View File

@ -161,8 +161,9 @@ class _I18nVisitor implements html.Visitor {
}
}
const _CUSTOM_PH_EXP = /\/\/[\s\S]*i18n[\s\S]*\([\s\S]*ph[\s\S]*=[\s\S]*"([\s\S]*?)"[\s\S]*\)/g;
const _CUSTOM_PH_EXP =
/\/\/[\s\S]*i18n[\s\S]*\([\s\S]*ph[\s\S]*=[\s\S]*("|')([\s\S]*?)\1[\s\S]*\)/g;
function _extractPlaceholderName(input: string): string {
return input.split(_CUSTOM_PH_EXP)[1];
return input.split(_CUSTOM_PH_EXP)[2];
}

View File

@ -125,6 +125,12 @@ export function main() {
.toEqual([
[['[before, <ph name="TEST"> exp //i18n(ph="teSt") </ph>, after]'], 'm', 'd'],
]);
expect(
_humanizeMessages('<div i18n=\'m|d\'>before{{ exp //i18n(ph=\'teSt\') }}after</div>'))
.toEqual([
[[`[before, <ph name="TEST"> exp //i18n(ph='teSt') </ph>, after]`], 'm', 'd'],
]);
});
});