add class on any namespace elments

This commit is contained in:
Misko Hevery 2011-02-22 15:19:22 -08:00
parent 08e3b1edbb
commit c7998f5f99
2 changed files with 9 additions and 1 deletions

View file

@ -173,6 +173,7 @@ Compiler.prototype = {
descend = true,
directives = true,
elementName = nodeName_(element),
elementNamespace = elementName.indexOf(':') > 0 ? lowercase(elementName).replace(':', '-') : '',
template,
selfApi = {
compile: bind(self, self.compile),
@ -186,6 +187,7 @@ Compiler.prototype = {
// for some reason IE throws error under some weird circumstances. so just assume nothing
priority = priority || 0;
}
element.addClass(elementNamespace);
if (isString(priority)) {
priority = PRIORITY[uppercase(priority)] || parseInt(priority, 10);
}
@ -200,7 +202,7 @@ Compiler.prototype = {
});
if (!widget) {
if (widget = self.widgets(elementName)) {
if (elementName.indexOf(':') > 0)
if (elementNamespace)
element.addClass('ng-widget');
widget = bind(selfApi, widget, element);
}

View file

@ -162,4 +162,10 @@ describe('compiler', function(){
scope = compile('A---B---C===D');
expect(sortedHtml(scope.$element)).toEqual('<div>A<hr></hr>B<hr></hr>C<p></p>D</div>');
});
it('should add class for namespace elements', function(){
scope = compile('<ng:space>abc</ng:space>');
var space = jqLite(scope.$element[0].firstChild);
expect(space.hasClass('ng-space')).toEqual(true);
});
});