diff --git a/src/ng/compile.js b/src/ng/compile.js index ae5b3cf9e2d3..34961a75eae7 100644 --- a/src/ng/compile.js +++ b/src/ng/compile.js @@ -2155,8 +2155,7 @@ function $CompileProvider($provide, $$sanitizeUriProvider) { afterTemplateChildLinkFn, beforeTemplateCompileNode = $compileNode[0], origAsyncDirective = directives.shift(), - // The fact that we have to copy and patch the directive seems wrong! - derivedSyncDirective = extend({}, origAsyncDirective, { + derivedSyncDirective = inherit(origAsyncDirective, { templateUrl: null, transclude: null, replace: null, $$originalDirective: origAsyncDirective }), templateUrl = (isFunction(origAsyncDirective.templateUrl)) diff --git a/test/ng/compileSpec.js b/test/ng/compileSpec.js index 5651647a75bc..570d9edb229d 100755 --- a/test/ng/compileSpec.js +++ b/test/ng/compileSpec.js @@ -1115,6 +1115,29 @@ describe('$compile', function() { expect(element.find('p').text()).toBe('Hello, world!'); }); }); + + it('should keep prototype properties on directive', function() { + module(function() { + function DirectiveClass() { + this.restrict = 'E'; + this.template = "
{{value}}
"; + } + + DirectiveClass.prototype.compile = function() { + return function(scope, element, attrs) { + scope.value = "Test Value"; + }; + }; + + directive('templateUrlWithPrototype', valueFn(new DirectiveClass())); + }); + + inject(function($compile, $rootScope) { + element = $compile('{{value}}
'); + element = $compile('