fix(compiler): xmb <ph> tags should not self close (#13413)

This commit is contained in:
Victor Berchet
2016-12-12 19:10:20 -08:00
parent 9e0e6b59d1
commit 4544b1d7a6
4 changed files with 10 additions and 9 deletions

View File

@ -119,11 +119,11 @@ class _Visitor implements i18n.Visitor {
}
visitPlaceholder(ph: i18n.Placeholder, context?: any): xml.Node[] {
return [new xml.Tag(_PLACEHOLDER_TAG, {name: ph.name})];
return [new xml.Tag(_PLACEHOLDER_TAG, {name: ph.name}, [], false)];
}
visitIcuPlaceholder(ph: i18n.IcuPlaceholder, context?: any): xml.Node[] {
return [new xml.Tag(_PLACEHOLDER_TAG, {name: ph.name})];
return [new xml.Tag(_PLACEHOLDER_TAG, {name: ph.name}, [], false)];
}
serialize(nodes: i18n.Node[]): xml.Node[] {

View File

@ -18,7 +18,8 @@ class _Visitor implements IVisitor {
const strAttrs = this._serializeAttributes(tag.attrs);
if (tag.children.length == 0) {
return `<${tag.name}${strAttrs}/>`;
return tag.canSelfClose ? `<${tag.name}${strAttrs}/>` :
`<${tag.name}${strAttrs}></${tag.name}>`;
}
const strChildren = tag.children.map(node => node.visit(this));
@ -71,8 +72,8 @@ export class Tag implements Node {
public attrs: {[k: string]: string} = {};
constructor(
public name: string, unescapedAttrs: {[k: string]: string} = {},
public children: Node[] = []) {
public name: string, unescapedAttrs: {[k: string]: string} = {}, public children: Node[] = [],
public canSelfClose: boolean = true) {
Object.keys(unescapedAttrs).forEach((k: string) => {
this.attrs[k] = _escapeXml(unescapedAttrs[k]);
});