Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add 'show_all', 'hide_all' methods on top level renderjson element#38

Open
movitto wants to merge 1 commit into
caldwell:master from
movitto:expand_hide_all
Open

Add 'show_all', 'hide_all' methods on top level renderjson element #38
movitto wants to merge 1 commit into
caldwell:master from
movitto:expand_hide_all

Conversation

@movitto

@movitto movitto commented Jun 19, 2020

Copy link
Copy Markdown

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

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
Comment thread renderjson.js
a.onclick = function(e) { callback(); if (e) e.stopPropagation(); return false; };
return a; };

var walkDOM = function(node, func){

@andifreed andifreed Jun 19, 2020

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

1 more reviewer

@andifreed andifreed andifreed left review comments

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /