Tree: Add buildFieldAnchor, and fix Bug#12687
Merged
Merged
Conversation
jenn-le
approved these changes
Oct 26, 2022
| parent, | ||
| field: "key", | ||
| }); | ||
| }); |
Contributor
There was a problem hiding this comment.
For consistency:
Suggested change
| }); | |
| }); | |
| enterNode(childIndex: number): void; | ||
|
|
||
| /** | ||
| * @returns a path to the current node. |
Contributor
There was a problem hiding this comment.
Minor suggestion: it could be useful to add an example of what the path should look like.
Contributor
Author
There was a problem hiding this comment.
I have added a link to FieldUpPath which defines this format. Putting example object literals inline here would be annoying to maintain if changing the FieldUpPath, so I think its better to just refer to it.
Co-authored-by: Jenn <jennle@microsoft.com>
CraigMacomber
added a commit
that referenced
this pull request
Oct 26, 2022
## Description Fix same bug as in #12687 except in cursorToJsonObject and generic JS object clone code for perf comparison. The old code would change the prototype of the object (via the __proto__ field defined on the prototype), while the new code adds an enumerable own property that shadows __proto__. benchmarks show a slight slowdown with this change, around 2-3% for cursorToJsonObject, and around 6% for the raw JS object clone reference.
sharptrip
pushed a commit
to sharptrip/FluidFramework
that referenced
this pull request
Oct 28, 2022
## Description This adds ITreeSubscriptionCursor.buildFieldAnchor and ITreeCursor.getFieldPath to support it. Additionally, this tweaks the Cursor tests cover a few more cases, and caught and fixes a bug in the handling of fields named __proto__: object.DefineProperty must be used to set such fields on objects! This also changes a few uses of Object.getOwnPropertyNames() to Object.keys() where enumerating fields from map like objects. Both actually work (as long as there are no non enumerable properties like methods), but only including enumerable properties seems more semantically correct and would work in more cases (though we don't care about those cases, it seems more robust).
sharptrip
pushed a commit
to sharptrip/FluidFramework
that referenced
this pull request
Oct 28, 2022
## Description Fix same bug as in microsoft#12687 except in cursorToJsonObject and generic JS object clone code for perf comparison. The old code would change the prototype of the object (via the __proto__ field defined on the prototype), while the new code adds an enumerable own property that shadows __proto__. benchmarks show a slight slowdown with this change, around 2-3% for cursorToJsonObject, and around 6% for the raw JS object clone reference.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
This adds ITreeSubscriptionCursor.buildFieldAnchor and ITreeCursor.getFieldPath to support it.
Additionally, this tweaks the Cursor tests cover a few more cases, and caught and fixes a bug in the handling of fields named proto: object.DefineProperty must be used to set such fields on objects!
This also changes a few uses of Object.getOwnPropertyNames() to Object.keys() where enumerating fields from map like objects. Both actually work (as long as there are no non enumerable properties like methods), but only including enumerable properties seems more semantically correct and would work in more cases (though we don't care about those cases, it seems more robust).