From c7998f5f992e9653b0c430316aadcbd7ecd47cb5 Mon Sep 17 00:00:00 2001 From: Misko Hevery Date: Tue, 22 Feb 2011 15:19:22 -0800 Subject: add class on any namespace elments --- src/Compiler.js | 4 +++- test/CompilerSpec.js | 6 ++++++ 2 files changed, 9 insertions(+), 1 deletion(-) 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('
A
B
C

D
'); }); + + it('should add class for namespace elements', function(){ + scope = compile('abc'); + var space = jqLite(scope.$element[0].firstChild); + expect(space.hasClass('ng-space')).toEqual(true); + }); }); -- cgit v1.2.3