Make anchor & alias resolution lazier #248
Merged
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.
Previously, the
source
of an alias node was a JS reference to the actual node object that it referred to, anddoc.anchors
provided separately from that the string identifiers used by YAML anchors.After this change, scalar and collection nodes get a new
anchor?: string
property, and thesource
of an alias is a string identifier. Thedoc.anchors
instance is completely dropped. ThecreateAlias()
method is moved to the document instance, and its handling of corner cases is changed a bit.As a consequence of these changes, assigning the same anchor to multiple nodes will no longer automatically rename an earlier anchor with the same name.
Node creation options are somewhat clarified and streamlined, and the
replacer
is moved from the options object to be an optional second argument of thecreateNode()
method, matching thenew Document()
interface.