aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMisko Hevery2011-02-22 15:19:22 -0800
committerMisko Hevery2011-02-22 15:23:08 -0800
commitc7998f5f992e9653b0c430316aadcbd7ecd47cb5 (patch)
tree59b410e98503b4bfd7ce8a3a62432dede3b47133
parent08e3b1edbb2923ad18c840c55eb95a14ab308daf (diff)
downloadangular.js-c7998f5f992e9653b0c430316aadcbd7ecd47cb5.tar.bz2
add class on any namespace elments
-rw-r--r--src/Compiler.js4
-rw-r--r--test/CompilerSpec.js6
2 files changed, 9 insertions, 1 deletions
diff --git a/src/Compiler.js b/src/Compiler.js
index 78d7a2b0..ae7bf83c 100644
--- a/src/Compiler.js
+++ b/src/Compiler.js
@@ -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);
}
diff --git a/test/CompilerSpec.js b/test/CompilerSpec.js
index f1e1c607..b1a881fb 100644
--- a/test/CompilerSpec.js
+++ b/test/CompilerSpec.js
@@ -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);
+ });
});