diff --git a/src/ng/compile.js b/src/ng/compile.js index 9285b253d0b3..e3fe900701cc 100644 --- a/src/ng/compile.js +++ b/src/ng/compile.js @@ -1234,14 +1234,22 @@ function $CompileProvider($provide, $$sanitizeUriProvider) { directiveValue = (isFunction(directive.template)) ? directive.template($compileNode, templateAttrs) : directive.template; + var elementTemplate = isElement(directiveValue); - directiveValue = denormalizeTemplate(directiveValue); + if (!elementTemplate) { + directiveValue = denormalizeTemplate(directiveValue); + } if (directive.replace) { replaceDirective = directive; - $template = jqLite('
Hello!
world!
') + })); })); @@ -675,6 +683,17 @@ describe('$compile', function() { }).not.toThrow(); }); }); + + + it('should accept DOM nodes as a template', inject(function($compile, $rootScope) { + if (!(msie < 9)) { + element = $compile('')($rootScope); + expect(element.find('g').length).toBe(0); + expect(element.find('circle').length).toBe(1); + } + element = $compile('')($rootScope); + expect(element.find('p').length).toBe(2); + })); }); @@ -693,6 +712,17 @@ describe('$compile', function() { expect($attrs.id).toBe('templateContent'); } })); + directive('svgCircle', valueFn({ + replace: true, + template: function() { + return jqLite('').children(); + } + })); + directive('domNodeTemplate', valueFn({ + template: function() { + return jqLite('Hello!
world!
'); + } + })); })); @@ -701,6 +731,17 @@ describe('$compile', function() { element = $compile('