diff --git a/src/ng/compile.js b/src/ng/compile.js index 5a082e9bb8c7..0aa2f0a4c0b4 100644 --- a/src/ng/compile.js +++ b/src/ng/compile.js @@ -3671,7 +3671,9 @@ var SPECIAL_CHARS_REGEXP = /[:\-_]+(.)/g; function directiveNormalize(name) { return name .replace(PREFIX_REGEXP, '') - .replace(SPECIAL_CHARS_REGEXP, fnCamelCaseReplace); + .replace(SPECIAL_CHARS_REGEXP, function(_, letter, offset) { + return offset ? letter.toUpperCase() : letter; + }); } /** diff --git a/test/ng/compileSpec.js b/test/ng/compileSpec.js index e3d923e6b1f6..8bd6fee9263c 100644 --- a/test/ng/compileSpec.js +++ b/test/ng/compileSpec.js @@ -305,6 +305,27 @@ describe('$compile', function() { inject(function($compile) {}); }); + it('should ignore special chars before processing attribute directive name', function() { + // a regression https://github.com/angular/angular.js/issues/16278 + module(function() { + directive('t', function(log) { + return { + restrict: 'A', + link: { + pre: log.fn('pre'), + post: log.fn('post') + } + }; + }); + }); + inject(function($compile, $rootScope, log) { + $compile('
')($rootScope); + $compile('')($rootScope); + $compile('')($rootScope); + expect(log).toEqual('pre; post; pre; post; pre; post'); + }); + }); + it('should throw an exception if the directive factory is not defined', function() { module(function() { expect(function() {