This repository was archived by the owner on Apr 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 27.4k
fix(parse): dirty checking support for objects with null prototype #9568
Closed
HeberLZ
wants to merge
8
commits into
angular:master
from
HeberLZ:parse-support-for-objects-that-dont-inherit-from-Object
Closed
Changes from 7 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
a45b1f6
enable dirty checking for objects created with Object.create(null) in…
HeberLZ 256f29f
Object.valueOf method cached as valueOfObject
HeberLZ 9123536
pr updated with newly cached method on Angular.js
HeberLZ a0fd098
updated to use own valueOf when available
HeberLZ dc5a43a
Test for Object.create(null) parsing added. Special thanks to Julian …
HeberLZ cc0c099
fix(parse): add support to Object.create(null) based bindings with th…
HeberLZ 443a43c
fix(parse): missing call to get the correct scope
HeberLZ 87f65fd
fix(parse): support parsing objects created with null prototype
HeberLZ File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1460,6 +1460,32 @@ describe('parser', function() { | |
expect(watcherCalls).toBe(1); | ||
})); | ||
|
||
it("should always reevaluate filters with non-primitive input created with Object.create(null)", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't call this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. or even without |
||
inject(function($parse) { | ||
var filterCalls = 0; | ||
$filterProvider.register('foo', valueFn(function(input) { | ||
filterCalls++; | ||
return input; | ||
})); | ||
|
||
var parsed = $parse('obj | foo'); | ||
var obj = scope.obj = Object.create(null); | ||
|
||
var watcherCalls = 0; | ||
scope.$watch(parsed, function(input) { | ||
expect(input).toBe(obj); | ||
watcherCalls++; | ||
}); | ||
|
||
scope.$digest(); | ||
expect(filterCalls).toBe(2); | ||
expect(watcherCalls).toBe(1); | ||
|
||
scope.$digest(); | ||
expect(filterCalls).toBe(3); | ||
expect(watcherCalls).toBe(1); | ||
})); | ||
|
||
it("should not reevaluate filters with non-primitive input that does support valueOf()", | ||
inject(function($parse) { | ||
var filterCalls = 0; | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
You can't do this this way, it needs to be