Add 'show_all', 'hide_all' methods on top level renderjson element#38
Open
movitto wants to merge 1 commit intocaldwell:masterfrom
Open
Add 'show_all', 'hide_all' methods on top level renderjson element#38movitto wants to merge 1 commit intocaldwell:masterfrom
movitto wants to merge 1 commit intocaldwell:masterfrom
Conversation
When called, these will walk down the renderjson DOM structure and
invoke 'show' and 'hide' on all the appropriate elements.
Use like so:
const rj = renderjson({ js : 'on })
document.getElementById("test").appendChild(rj);
rj.show_all();
rj.hide_all();
// ^ wire these up to a button click, etc
andifreed
reviewed
Jun 19, 2020
| a.onclick = function(e) { callback(); if (e) e.stopPropagation(); return false; }; | ||
| return a; }; | ||
|
|
||
| var walkDOM = function(node, func){ |
There was a problem hiding this comment.
This is an interesting function, and use case. But not all json object graphs are tree. We explicitly, turn the tree back into a graph (for complex DTO object graphs and json schema), before rendering them.
https://github.com/andifreed/renderjson/blob/50a85654206671137e397d9d92996a94f4e9b06a/resolvejson.js
But there may be other graphs passed to this renderer, you can make it impervious to such infinite recursion by adding a array|stack parameter and checking that the object hasn't been seen yet before descending. Besure to put before descending and pop after returning.
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.
When called, these will walk down the renderjson DOM structure and invoke 'show' and 'hide' on all the appropriate elements.
Use like so: