From 9fbafba993207cba3e23f050f4740fe9a0647d49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matias=20Niemel=C3=A4?= Date: Fri, 29 Apr 2016 14:54:46 -0700 Subject: [PATCH] chore(parsing): change internal usage of `@` to `:` for namespaced values Closes #8346 --- modules/@angular/compiler/src/html_tags.ts | 6 +++--- modules/@angular/compiler/test/html_parser_spec.ts | 12 ++++++------ .../@angular/compiler/test/template_parser_spec.ts | 12 ++++++------ .../platform-browser/src/dom/dom_renderer.ts | 4 ++-- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/modules/@angular/compiler/src/html_tags.ts b/modules/@angular/compiler/src/html_tags.ts index f91647636a..7f89db4035 100644 --- a/modules/@angular/compiler/src/html_tags.ts +++ b/modules/@angular/compiler/src/html_tags.ts @@ -408,10 +408,10 @@ export function getHtmlTagDefinition(tagName: string): HtmlTagDefinition { return isPresent(result) ? result : DEFAULT_TAG_DEFINITION; } -var NS_PREFIX_RE = /^@([^:]+):(.+)/g; +var NS_PREFIX_RE = /^:([^:]+):(.+)/g; export function splitNsName(elementName: string): string[] { - if (elementName[0] != '@') { + if (elementName[0] != ':') { return [null, elementName]; } let match = RegExpWrapper.firstMatch(NS_PREFIX_RE, elementName); @@ -423,5 +423,5 @@ export function getNsPrefix(elementName: string): string { } export function mergeNsAndName(prefix: string, localName: string): string { - return isPresent(prefix) ? `@${prefix}:${localName}` : localName; + return isPresent(prefix) ? `:${prefix}:${localName}` : localName; } diff --git a/modules/@angular/compiler/test/html_parser_spec.ts b/modules/@angular/compiler/test/html_parser_spec.ts index dbeb8c6c1b..2466b65520 100644 --- a/modules/@angular/compiler/test/html_parser_spec.ts +++ b/modules/@angular/compiler/test/html_parser_spec.ts @@ -154,17 +154,17 @@ export function main() { it('should support explicit mamespace', () => { expect(humanizeDom(parser.parse('', 'TestComp'))) - .toEqual([[HtmlElementAst, '@myns:div', 0]]); + .toEqual([[HtmlElementAst, ':myns:div', 0]]); }); it('should support implicit mamespace', () => { expect(humanizeDom(parser.parse('', 'TestComp'))) - .toEqual([[HtmlElementAst, '@svg:svg', 0]]); + .toEqual([[HtmlElementAst, ':svg:svg', 0]]); }); it('should propagate the namespace', () => { expect(humanizeDom(parser.parse('

', 'TestComp'))) - .toEqual([[HtmlElementAst, '@myns:div', 0], [HtmlElementAst, '@myns:p', 1]]); + .toEqual([[HtmlElementAst, ':myns:div', 0], [HtmlElementAst, ':myns:p', 1]]); }); it('should match closing tags case sensitive', () => { @@ -184,7 +184,7 @@ export function main() { it('should support self closing foreign elements', () => { expect(humanizeDom(parser.parse('', 'TestComp'))) - .toEqual([[HtmlElementAst, '@math:math', 0]]); + .toEqual([[HtmlElementAst, ':math:math', 0]]); }); it('should ignore LF immediately after textarea, pre and listing', () => { @@ -221,7 +221,7 @@ export function main() { it('should parse attributes on svg elements case sensitive', () => { expect(humanizeDom(parser.parse('', 'TestComp'))) - .toEqual([[HtmlElementAst, '@svg:svg', 0], [HtmlAttrAst, 'viewBox', '0']]); + .toEqual([[HtmlElementAst, ':svg:svg', 0], [HtmlAttrAst, 'viewBox', '0']]); }); it('should parse attributes on template elements', () => { @@ -231,7 +231,7 @@ export function main() { it('should support namespace', () => { expect(humanizeDom(parser.parse('', 'TestComp'))) - .toEqual([[HtmlElementAst, '@svg:use', 0], [HtmlAttrAst, '@xlink:href', 'Port']]); + .toEqual([[HtmlElementAst, ':svg:use', 0], [HtmlAttrAst, ':xlink:href', 'Port']]); }); }); diff --git a/modules/@angular/compiler/test/template_parser_spec.ts b/modules/@angular/compiler/test/template_parser_spec.ts index 9daab63f28..b0d5144b61 100644 --- a/modules/@angular/compiler/test/template_parser_spec.ts +++ b/modules/@angular/compiler/test/template_parser_spec.ts @@ -146,7 +146,7 @@ export function main() { var parsed = parse('', []); expect(humanizeTplAst(parsed)) .toEqual([ - [ElementAst, '@svg:svg'], + [ElementAst, ':svg:svg'], [NgContentAst], ]); }); @@ -854,7 +854,7 @@ There is no directive with "exportAs" set to "dirA" ("
]#a="dirA">< () => { expect(humanizeTplAst(parse('', []))) .toEqual([ - [ElementAst, '@svg:svg'], + [ElementAst, ':svg:svg'], [EmbeddedTemplateAst], ]); }); @@ -1423,11 +1423,11 @@ Property binding a not used by any directive on an embedded template ("[ERROR -> expect(humanizeTplAstSourceSpans( parse('', [tagSel, attrSel]))) .toEqual([ - [ElementAst, '@svg:svg', ''], - [ElementAst, '@svg:circle', ''], + [ElementAst, ':svg:svg', ''], + [ElementAst, ':svg:circle', ''], [DirectiveAst, tagSel, ''], - [ElementAst, '@svg:use', ''], - [AttrAst, '@xlink:href', 'Port', 'xlink:href="Port"'], + [ElementAst, ':svg:use', ''], + [AttrAst, ':xlink:href', 'Port', 'xlink:href="Port"'], [DirectiveAst, attrSel, ''], ]); }); diff --git a/modules/@angular/platform-browser/src/dom/dom_renderer.ts b/modules/@angular/platform-browser/src/dom/dom_renderer.ts index 2d06236765..840fa6de7a 100644 --- a/modules/@angular/platform-browser/src/dom/dom_renderer.ts +++ b/modules/@angular/platform-browser/src/dom/dom_renderer.ts @@ -328,10 +328,10 @@ function _flattenStyles(compId: string, styles: Array, target: stri return target; } -var NS_PREFIX_RE = /^@([^:]+):(.+)/g; +var NS_PREFIX_RE = /^:([^:]+):(.+)/g; function splitNamespace(name: string): string[] { - if (name[0] != '@') { + if (name[0] != ':') { return [null, name]; } let match = RegExpWrapper.firstMatch(NS_PREFIX_RE, name);