From 58e94dcde9bba6ad4798a0f910a9112c03e5a3c2 Mon Sep 17 00:00:00 2001 From: Igor Minar Date: Sat, 12 Jul 2014 20:23:32 -0700 Subject: [PATCH] docs($parse:isecdom): add a section about return values and CoffeeScript Closes #7973 --- docs/content/error/$parse/isecdom.ngdoc | 31 +++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/docs/content/error/$parse/isecdom.ngdoc b/docs/content/error/$parse/isecdom.ngdoc index 666bf36cb..9f60e189e 100644 --- a/docs/content/error/$parse/isecdom.ngdoc +++ b/docs/content/error/$parse/isecdom.ngdoc @@ -14,3 +14,34 @@ perform this check - it's up to the developer to not expose such sensitive and p directly on the scope chain. To resolve this error, avoid access to DOM nodes. + + +# Event Handlers and Return Values + +The `$parse:isecdom` error also occurs when an event handler invokes a function that returns a DOM +node. + +```html + +``` + +```js + $scope.iWillReturnDOM = function() { + return someDomNode; + } +``` + +To fix this issue, avoid returning DOM nodes from event handlers. + +*Note: This error often means that you are accessing DOM from your controllers, which is usually +a sign of poor coding style that violates separation of concerns.* + + +# Implicit Returns in CoffeeScript + +This error can occur more frequently when using CoffeeScript, which has a feature called implicit +returns. This language feature returns the last dereferenced object in the function when the +function has no explicit return statement. + +The solution in this scenario is to add an explicit return statement. For example `return false` to +the function.