Skip to content
This repository was archived by the owner on Apr 4, 2025. It is now read-only.

fix(scopes) handle watches on null expression #103

Merged
merged 1 commit into from
Aug 14, 2015

Conversation

gary-b
Copy link
Contributor

@gary-b gary-b commented Jul 16, 2015

Passing null as first parameter to the $scope.$watch function caused a null reference exception within hint.js that interferes with the loading of the users app. Adding a null check to resolve this issue.

Fixes issue #94

Passing null as first parameter to the $scope.$watch function caused
a null reference exception within hint.js that interferes with the
loading of the users app. Adding a null check to resolve this issue.

Fixes issue angular#94
@@ -304,6 +304,9 @@ function byScopeId (scope) {
}

function humanReadableWatchExpression (fn) {
if (fn == null) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

strict equals, please!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually think this is fine since it'll also handle null elegantly.

@SomeKittens
Copy link
Member

Just the equals thing, otherwise looks great! Thanks again

@gary-b
Copy link
Contributor Author

gary-b commented Jul 17, 2015

Hi SomeKittens

The intention here is to catch undefined as well as null, as the same bug will occur with undefined. Perhaps i am wrong to always be returning null, might be best to return fn, so it correctly reports what the user passed in - ill change that sure and add a test for the undefined scenario.
Would you like me to use strict equals to check for both null and undefined as well, or will loose equals be OK now?

@SomeKittens
Copy link
Member

Just strictly check for both fn === null || fn === undefined

@btford
Copy link
Contributor

btford commented Aug 14, 2015

I actually prefer @gary-b's way.

btford added a commit that referenced this pull request Aug 14, 2015
fix(scopes): handle watches on null expression
@btford btford merged commit 459eace into angular:master Aug 14, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants