From a4c8c8713c4f83a6dee406e8dd53a0c21b8f7656 Mon Sep 17 00:00:00 2001 From: Misko Hevery Date: Thu, 1 Aug 2013 15:09:35 -0700 Subject: [PATCH 1/6] docs(compile/iscp): description for compile/iscp error --- docs/content/error/compile/iscp.ngdoc | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/docs/content/error/compile/iscp.ngdoc b/docs/content/error/compile/iscp.ngdoc index afdbd4c4e8d..3c5c3208a6a 100644 --- a/docs/content/error/compile/iscp.ngdoc +++ b/docs/content/error/compile/iscp.ngdoc @@ -2,3 +2,21 @@ @name $compile:iscp @fullName Invalid Isolate Scope @description +When {@link guide/directive#directivedefinitionobject declaring isolate scope} the scope definition object must +be in specific format which starts with mode character (`@&=`) with an optional local name. + +
+myModule.directive('directiveName', function factory() {
+  return {
+    ...
+    scope: {
+      'attrName': '@', // OK
+      'attrName2': '=localName', // OK
+      'attrName3': 'name',    // ERROR: missing mode @&=
+      'attrName4': ' = name', // ERROR: extra spaces
+      'attrName5': 'name=',   // ERROR: must be prefixed with @&=
+    }
+    ...
+  }
+});
+
From eb8dd2bd440f5cb2c2a167e3a7bbbc98f78ab342 Mon Sep 17 00:00:00 2001 From: Misko Hevery Date: Thu, 1 Aug 2013 15:28:18 -0700 Subject: [PATCH 2/6] docs(compile/multidir): description for compile/multidir error --- docs/content/error/compile/multidir.ngdoc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/docs/content/error/compile/multidir.ngdoc b/docs/content/error/compile/multidir.ngdoc index 4e893c3e555..f9583e0162a 100644 --- a/docs/content/error/compile/multidir.ngdoc +++ b/docs/content/error/compile/multidir.ngdoc @@ -2,3 +2,12 @@ @name $compile:multidir @fullName Multiple Directive Resource Contention @description +When multiple directives are triggered on a single DOM element, they may request incompatible/unsupported configuration +which results in this error. The solution is to remove one of the directives which is causing the colsion. + +Examples are: + +* Multiple `isolated scopes` per element. +* Same `controller name` published more then one directive. +* Multiple directives declared with `transclusion`. +* Multiple directives attempting to defined a `template` or `templateURL`. From 1d124e39b10d1ac289d29e4977ce905c01e0850e Mon Sep 17 00:00:00 2001 From: Misko Hevery Date: Thu, 1 Aug 2013 15:39:22 -0700 Subject: [PATCH 3/6] docs(compile/notassign): description for compile/notassign error --- docs/content/error/compile/noass.ngdoc | 4 --- docs/content/error/compile/notassign.ngdoc | 30 ++++++++++++++++++++++ src/ng/compile.js | 2 +- 3 files changed, 31 insertions(+), 5 deletions(-) delete mode 100644 docs/content/error/compile/noass.ngdoc create mode 100644 docs/content/error/compile/notassign.ngdoc diff --git a/docs/content/error/compile/noass.ngdoc b/docs/content/error/compile/noass.ngdoc deleted file mode 100644 index bb247499ec5..00000000000 --- a/docs/content/error/compile/noass.ngdoc +++ /dev/null @@ -1,4 +0,0 @@ -@ngdoc error -@name $compile:noass -@fullName Non-Assignable Expression -@description diff --git a/docs/content/error/compile/notassign.ngdoc b/docs/content/error/compile/notassign.ngdoc new file mode 100644 index 00000000000..429125ec57f --- /dev/null +++ b/docs/content/error/compile/notassign.ngdoc @@ -0,0 +1,30 @@ +@ngdoc error +@name $compile:notassign +@fullName Non-Assignable Expression +@description + +When {@link guide/directive#directivedefinitionobject declaring isolate scope} using the `=` mode the expression +must be assignable. + +
+myModule.directive('myDirective', function factory() {
+  return {
+    ...
+    scope: {
+      'bind': '@localValue'
+    }
+    ...
+  }
+});
+
+ +Example which does not cause error: +
+  
+
+ +Examples which will cause errors when the `myDirective` attempts to change the value of `localValue`. +
+   ERROR: this statement makes no sense: 1+2=localValue
+   ERROR: this statement makes no sense: myFn()=localValue
+
diff --git a/src/ng/compile.js b/src/ng/compile.js index 6aebe537752..9229ce2227f 100644 --- a/src/ng/compile.js +++ b/src/ng/compile.js @@ -916,7 +916,7 @@ function $CompileProvider($provide) { parentSet = parentGet.assign || function() { // reset the change, or we will throw this exception on every $digest lastValue = scope[scopeName] = parentGet(parentScope); - throw $compileMinErr('noass', "Expression '{0}' used with directive '{1}' is non-assignable!", + throw $compileMinErr('notassign', "Expression '{0}' used with directive '{1}' is non-assignable!", attrs[attrName], newIsolateScopeDirective.name); }; lastValue = scope[scopeName] = parentGet(parentScope); From 12e1714ff441ac0631b2eb55f6c60d5a640a51d0 Mon Sep 17 00:00:00 2001 From: Misko Hevery Date: Thu, 1 Aug 2013 15:46:36 -0700 Subject: [PATCH 4/6] docs(compile/nodomevents): description for compile/nodomevents error --- docs/content/error/compile/nodomevents.ngdoc | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/docs/content/error/compile/nodomevents.ngdoc b/docs/content/error/compile/nodomevents.ngdoc index 421e896f249..3a3bad70918 100644 --- a/docs/content/error/compile/nodomevents.ngdoc +++ b/docs/content/error/compile/nodomevents.ngdoc @@ -2,3 +2,13 @@ @name $compile:nodomevents @fullName Interpolated Event Attributes @description + +In this example the `onclick` binding will be ignored. There is no practical value in binding the user input to the +`onclick` event and could result in script injection if the user would enter `javascript:alert('PWND')` into the input +field. +
+
+
click me
+
+ +For this reasons we prevent `{{}}` bindings on `formaction` and all attributes which start with `on`. From e7f54f1dc41c71e13349d03e2216e67167a28374 Mon Sep 17 00:00:00 2001 From: Misko Hevery Date: Thu, 1 Aug 2013 15:53:59 -0700 Subject: [PATCH 5/6] docs(compile/selmulti): description for compile/selmulti error --- docs/content/error/compile/selmulti.ngdoc | 10 ++++++++++ src/ng/compile.js | 2 +- test/ng/compileSpec.js | 2 +- test/ng/directive/booleanAttrsSpec.js | 2 +- 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/docs/content/error/compile/selmulti.ngdoc b/docs/content/error/compile/selmulti.ngdoc index d737ca35511..f3744af429c 100644 --- a/docs/content/error/compile/selmulti.ngdoc +++ b/docs/content/error/compile/selmulti.ngdoc @@ -2,3 +2,13 @@ @name $compile:selmulti @fullName Binding to Multiple Attribute @description + +Binding to `multiple` on select is not allowed since switching between multiple and single mode changes the `ng-model` +object type from instance to array of instances which breaks the model semantics. Use +{@link api/ng.directive:ngSwitch ng-switch} directive to work around this issue and allow different `ng-model` +definitions for single and multiple mode. + +
+
+
+ diff --git a/src/ng/compile.js b/src/ng/compile.js index 9229ce2227f..97f36168489 100644 --- a/src/ng/compile.js +++ b/src/ng/compile.js @@ -1229,7 +1229,7 @@ function $CompileProvider($provide) { if (name === "multiple" && nodeName_(node) === "SELECT") { - throw $compileMinErr("selmulti", "Binding to the multiple attribute is not supported. Element: {0}", + throw $compileMinErr("selmulti", "Binding to the 'multiple' attribute is not supported. Element: {0}", startingTag(node)); } diff --git a/test/ng/compileSpec.js b/test/ng/compileSpec.js index c1dedd4ab72..c6e955998dc 100755 --- a/test/ng/compileSpec.js +++ b/test/ng/compileSpec.js @@ -2110,7 +2110,7 @@ describe('$compile', function() { componentScope.ref = 'ignore me'; expect($rootScope.$apply). - toThrow("[$compile:noass] Expression ''hello ' + name' used with directive 'myComponent' is non-assignable!"); + toThrow("[$compile:notassign] Expression ''hello ' + name' used with directive 'myComponent' is non-assignable!"); expect(componentScope.ref).toBe('hello world'); // reset since the exception was rethrown which prevented phase clearing $rootScope.$$phase = null; diff --git a/test/ng/directive/booleanAttrsSpec.js b/test/ng/directive/booleanAttrsSpec.js index 93e8cc20f7f..02e135edf9c 100644 --- a/test/ng/directive/booleanAttrsSpec.js +++ b/test/ng/directive/booleanAttrsSpec.js @@ -93,7 +93,7 @@ describe('boolean attr directives', function() { expect(function() { $compile('') - }).toThrow('[$compile:selmulti] Binding to the multiple attribute is not supported. ' + + }).toThrow('[$compile:selmulti] Binding to the \'multiple\' attribute is not supported. ' + 'Element: