mirror of
https://github.com/zhigang1992/angular.js.git
synced 2026-04-04 08:58:16 +08:00
add class on any namespace elments
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user