support json parsing to hx-live data proxy#3822
Open
MichaelWest22 wants to merge 1 commit into
Open
Conversation
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
in hx-live we have a new data proxy and we have found that if we use JSON parse and stringify we can store and retrive data and retain the JSON supported data types like boolean, numeric and arrays. This works well for all data I have tested for except strings of numbers with leading zero which will be converted to a number. But this seems and unlikely edge case and you can work around this by accessing the this.dataset.xxxx directly.
I've also extended q() to have data as a proxy of the data for the first returned element.
Also found parseConfig can use the JSON.parse trick here as well to replace the true, false and numeric handling with a simple json parse. From my testing this works well for all the situations I could find. JSON.parse auto converts true, false and number strings to their real type.
Finally I also extended morphIgnore to handle prefixes with startsWith() as well so that it is possible to easily use this to protect client side data-* attributes if needed.
Corresponding issue:
Testing
added some hx-live tests for the data proxy.
Checklist
masterfor website changes,devforsource changes)
approved via an issue
npm run test) and verified that it succeeded