From 28fd2477d4f4c638bd63cc5ce1fc3e2b695fb10f Mon Sep 17 00:00:00 2001 From: Jason Bedard Date: Fri, 6 Nov 2015 00:25:29 -0800 Subject: [PATCH] refactor($compile): move check for interpolation of on-event attributes to compile time BREAKING CHANGE: Previously the nodomevents would be thrown at link time for any interpolation on* event attributes. Now this will be throw at compile time similar to the selmulti error. --- src/ng/compile.js | 12 ++++++------ test/ng/compileSpec.js | 6 +++--- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/ng/compile.js b/src/ng/compile.js index 8b6491091de7..f3cb311a20e7 100644 --- a/src/ng/compile.js +++ b/src/ng/compile.js @@ -2534,6 +2534,12 @@ function $CompileProvider($provide, $$sanitizeUriProvider) { startingTag(node)); } + if (EVENT_HANDLER_ATTR_REGEXP.test(name)) { + throw $compileMinErr('nodomevents', + "Interpolations for HTML DOM event attributes are disallowed. Please use the " + + "ng- versions (such as ng-click instead of onclick) instead."); + } + directives.push({ priority: 100, compile: function() { @@ -2541,12 +2547,6 @@ function $CompileProvider($provide, $$sanitizeUriProvider) { pre: function attrInterpolatePreLinkFn(scope, element, attr) { var $$observers = (attr.$$observers || (attr.$$observers = createMap())); - if (EVENT_HANDLER_ATTR_REGEXP.test(name)) { - throw $compileMinErr('nodomevents', - "Interpolations for HTML DOM event attributes are disallowed. Please use the " + - "ng- versions (such as ng-click instead of onclick) instead."); - } - // If the attribute has changed since last $interpolate()ed var newValue = attr[name]; if (newValue !== value) { diff --git a/test/ng/compileSpec.js b/test/ng/compileSpec.js index da016f74c5ac..d19493e19924 100755 --- a/test/ng/compileSpec.js +++ b/test/ng/compileSpec.js @@ -7795,17 +7795,17 @@ describe('$compile', function() { // All interpolations are disallowed. $rootScope.onClickJs = ""; expect(function() { - $compile('