Skip to content

Commit 05d3ed0

Browse files
docs(error/isecwindow): add note about coffeescript issue
Closes angular#4853
1 parent 1b25f80 commit 05d3ed0

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

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

+29
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,32 @@ 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 Window access.
17+
18+
### Common CoffeeScript Issue
19+
20+
Be aware that if you are using CoffeeScript, it automatically returns the value of the last statement in a
21+
function. So for instance
22+
23+
```coffeescript
24+
scope.foo = ->
25+
window.open 'https://example.com'
26+
```
27+
28+
compiles to something like
29+
30+
```js
31+
scope.foo = function() {
32+
return window.open('https://example.com');
33+
};
34+
```
35+
36+
You can see that this function will return the result of calling `window.open`, which is a `Window`
37+
object.
38+
39+
You can avoid this by explicitly returning something else from the function:
40+
41+
```coffeescript
42+
scope.foo = ->
43+
window.open 'https://example.com'
44+
return true;
45+
```

0 commit comments

Comments
 (0)