Use a proper tag for !!merge <<
keys
#580
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.
Fixes #579
Let's handle
!!merge <<
like other explicit YAML 1.1 tags, so that it works even if not separately enabled, and fix the options so thatmerge: true
is a shorthand forcustomTags: ['merge']
(and combines with that option nicely, if they're both used).This turned out to be a bit tricky to do "right", while also not introducing any breaking changes. In YAML 1.1,
<<
is special, but only if it's used as a bare mapping key, and so I added anatKey
flag into theComposeContext
and adefault: 'key'
value for tags, so that composition can take the node position into account.The difficulty here is slightly compounded by a mistake we made early on (#22, CC @ikatyang) in mis-reading the
!!merge
spec and allowing multiple<<
keys to be present in a single mapping, which is not valid YAML -- but removing this support now would count as a breaking change, and that would be unfortunate.While at this, I took the opportunity to add an optional
addToJSMap(ctx, map, value)
method that!!merge
can use to customize how it's added to a JS map, so that its handling is now much less custom.