From af520947aa6e3ba96e3234c093ce3426fe594395 Mon Sep 17 00:00:00 2001 From: Victor Berchet Date: Fri, 30 Sep 2016 15:50:59 -0700 Subject: [PATCH] test(AstSerializer): fix serializing void tags --- .../compiler/test/i18n/serializers/xliff_spec.ts | 4 ++-- .../compiler/test/ml_parser/ast_serializer_spec.ts | 10 +++++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/modules/@angular/compiler/test/i18n/serializers/xliff_spec.ts b/modules/@angular/compiler/test/i18n/serializers/xliff_spec.ts index a5322f94ff..6a6b9a71cb 100644 --- a/modules/@angular/compiler/test/i18n/serializers/xliff_spec.ts +++ b/modules/@angular/compiler/test/i18n/serializers/xliff_spec.ts @@ -42,7 +42,7 @@ const WRITE_XLIFF = ` ph names - + @@ -116,7 +116,7 @@ export function main(): void { 'ec1d033f2436133c14ab038286c4f5df4697484a': '{{ interpolation}} footnemele elbatalsnart sredlohecalp htiw', 'db3e0a6a5a96481f60aec61d98c3eecddef5ac23': 'oof', - 'd7fa2d59aaedcaa5309f13028c59af8c85b8c49d': '


', + 'd7fa2d59aaedcaa5309f13028c59af8c85b8c49d': '

', }); }); }); diff --git a/modules/@angular/compiler/test/ml_parser/ast_serializer_spec.ts b/modules/@angular/compiler/test/ml_parser/ast_serializer_spec.ts index 15f181c3c7..129e2e7658 100644 --- a/modules/@angular/compiler/test/ml_parser/ast_serializer_spec.ts +++ b/modules/@angular/compiler/test/ml_parser/ast_serializer_spec.ts @@ -6,9 +6,9 @@ * found in the LICENSE file at https://angular.io/license */ -import {beforeEach, describe, expect, it} from '../../../core/testing/testing_internal'; -import * as html from '../../src/ml_parser/ast'; -import {HtmlParser} from '../../src/ml_parser/html_parser'; +import * as html from '@angular/compiler/src/ml_parser/ast'; +import {HtmlParser} from '@angular/compiler/src/ml_parser/html_parser'; +import {getHtmlTagDefinition} from '@angular/compiler/src/ml_parser/html_tags'; export function main() { describe('Node serializer', () => { @@ -62,6 +62,10 @@ export function main() { class _SerializerVisitor implements html.Visitor { visitElement(element: html.Element, context: any): any { + if (getHtmlTagDefinition(element.name).isVoid) { + return `<${element.name}${this._visitAll(element.attrs, ' ')}/>`; + } + return `<${element.name}${this._visitAll(element.attrs, ' ')}>${this._visitAll(element.children)}`; }