Skip to content

Commit af20a8a

Browse files
committed
docs($parse:isecdom): add a section about return values and CoffeeScript
Closes #7973
1 parent d15cea4 commit af20a8a

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

docs/content/error/$parse/isecdom.ngdoc

+31
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,34 @@ perform this check - it's up to the developer to not expose such sensitive and p
1414
directly on the scope chain.
1515

1616
To resolve this error, avoid access to DOM nodes.
17+
18+
19+
# Event Handlers and Return Values
20+
21+
The `$parse:isecdom` error also occurs when an event handler invokes a function that returns a DOM
22+
node.
23+
24+
```html
25+
<button ng-click="iWillReturnDOM()">click me</button>
26+
```
27+
28+
```js
29+
$scope.iWillReturnDOM = function() {
30+
return someDomNode;
31+
}
32+
```
33+
34+
To fix this issue, avoid returning DOM nodes from event handlers.
35+
36+
*Note: This error often means that you are accessing DOM from your controllers, which is usually
37+
a sign of poor coding style that violates separation of concerns.*
38+
39+
40+
# Implicit Returns in CoffeeScript
41+
42+
This error can occur more frequently when using CoffeeScript, which has a feature called implicit
43+
returns. This language feature returns the last dereferenced object in the function when the
44+
function has no explicit return statement.
45+
46+
The solution in this scenario is to add an explicit return statement. For example `return false` to
47+
the function.

0 commit comments

Comments
 (0)