fix(references): value object references now work #623
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.
Issue #, if available: #615
Description of changes: Token values that are objects as opposed to simple strings were not working with
outputReferences
and throwing an error. These changes fix some behavior and make sure certain scenarios don't fail. This makes explicit whatoutputReferences
can and can't do:value
must be a string at time of formatting. This should be the case anyways, if not you will get[object Object]
in output files. WithoutputReferences
this was failing because an object does not have the.replace
function.value
must have the referenced values in it foroutputReferences
to replace the resolved values with the reference's name. For example if you define a color using an HSL object and transform it to a hex value, we cannot undo that transform to understand which parts of the value to use the reference's name.Here are the changes:
createPropertyFormatter
, rather than looking at the original value and replacing references with the referenced token's name, we are now looking at the transformed value and replacing any referenced values with the reference's name. This allows us to still useoutputReferences
with a value object.outputReferences
. It will build fine, but just won't output the reference and instead output the transformed and resolved value. An example of this is converting an HSL object to a Hex string.outputReferences
because the references will not have aname
attribute. Just like the previous point, it will build fine, but just won't output the reference and instead output the transformed and resolved value.getReferences
to mirrorusesReference
with respect to object values.usesReference
checks the object values, whereasgetReferences
did not.Added some unit tests to
getReferences
to verify behavior.Added integration tests to verify different behaviors:
outputReferences
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.