-
Notifications
You must be signed in to change notification settings - Fork 27.4k
refactor($parse): change 'this' to a $parse keyword instead of scope field #9105
Conversation
This is good to me. |
02dc2aa
to
fd2d6c0
Compare
I would actually be interested in seeing the performance difference between this and properties, though. One potential issue with it is that it overwrites the It's kind of an elegant solution though |
@@ -128,7 +128,7 @@ function $RootScopeProvider(){ | |||
this.$$phase = this.$parent = this.$$watchers = | |||
this.$$nextSibling = this.$$prevSibling = | |||
this.$$childHead = this.$$childTail = null; | |||
this['this'] = this.$root = this; | |||
this.$root = this; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since you're changing this, please remove the extra space character after the =
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
That potential issue is one of the breaking changes. I think it is a good thing though, now it is consistent with accessing other keyword properties such as 'null', 'false', etc. The performance when using 'this' will be worse because it will now be a field-access (which wraps 2 getters), where previously it was a single getter. But I think the use of 'this' in expressions is rare enough that removing |
@tbosch can you lgtm this? There's a tiny breaking change, but I don't think it's likely to affect anyone really |
…field BREAKING CHANGE: - $scope['this'] no longer exits on the $scope object - $parse-ed expressions no longer allow chaining 'this' such as this['this'] or $parent['this'] - 'this' in $parse-ed expressions can no longer be overriden, if a variable named 'this' is put on the scope it must be accessed using this['this']
lgtm |
BREAKING CHANGE:
I think this is a cleaner way of implementing 'this' which is more like other keywords such as
null
orfalse
. But it is also a breaking change for anyone that did weird things such asthis.this.this.this
(and less weird:$scope['this'] = ...
).