chore(parsing): change internal usage of `@` to `:` for namespaced values

Closes #8346
This commit is contained in:
Matias Niemelä 2016-04-29 14:54:46 -07:00 committed by Martin Probst
parent 7a524e3deb
commit 9fbafba993
4 changed files with 17 additions and 17 deletions

View File

@ -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;
}

View File

@ -154,17 +154,17 @@ export function main() {
it('should support explicit mamespace', () => {
expect(humanizeDom(parser.parse('<myns:div></myns:div>', 'TestComp')))
.toEqual([[HtmlElementAst, '@myns:div', 0]]);
.toEqual([[HtmlElementAst, ':myns:div', 0]]);
});
it('should support implicit mamespace', () => {
expect(humanizeDom(parser.parse('<svg></svg>', 'TestComp')))
.toEqual([[HtmlElementAst, '@svg:svg', 0]]);
.toEqual([[HtmlElementAst, ':svg:svg', 0]]);
});
it('should propagate the namespace', () => {
expect(humanizeDom(parser.parse('<myns:div><p></p></myns:div>', '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('<math />', '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('<svg viewBox="0"></svg>', '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('<svg:use xlink:href="Port" />', 'TestComp')))
.toEqual([[HtmlElementAst, '@svg:use', 0], [HtmlAttrAst, '@xlink:href', 'Port']]);
.toEqual([[HtmlElementAst, ':svg:use', 0], [HtmlAttrAst, ':xlink:href', 'Port']]);
});
});

View File

@ -146,7 +146,7 @@ export function main() {
var parsed = parse('<svg><ng-content></ng-content></svg>', []);
expect(humanizeTplAst(parsed))
.toEqual([
[ElementAst, '@svg:svg'],
[ElementAst, ':svg:svg'],
[NgContentAst],
]);
});
@ -854,7 +854,7 @@ There is no directive with "exportAs" set to "dirA" ("<div [ERROR ->]#a="dirA"><
() => {
expect(humanizeTplAst(parse('<svg><template></template></svg>', [])))
.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('<svg><circle /><use xlink:href="Port" /></svg>', [tagSel, attrSel])))
.toEqual([
[ElementAst, '@svg:svg', '<svg>'],
[ElementAst, '@svg:circle', '<circle />'],
[ElementAst, ':svg:svg', '<svg>'],
[ElementAst, ':svg:circle', '<circle />'],
[DirectiveAst, tagSel, '<circle />'],
[ElementAst, '@svg:use', '<use xlink:href="Port" />'],
[AttrAst, '@xlink:href', 'Port', 'xlink:href="Port"'],
[ElementAst, ':svg:use', '<use xlink:href="Port" />'],
[AttrAst, ':xlink:href', 'Port', 'xlink:href="Port"'],
[DirectiveAst, attrSel, '<use xlink:href="Port" />'],
]);
});

View File

@ -328,10 +328,10 @@ function _flattenStyles(compId: string, styles: Array<any | any[]>, 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);