4 ms·
Perfect candidate for a nice, simple, self-contained web component / custom element. Instead of: <div id="json-tree"></div> ... const container = d
by WA 2y ago
Perfect candidate for a nice, simple, self-contained web component / custom element. Instead of:
<div id="json-tree"></div>
...
const container = document.getElementById('json-tree');
container.innerHTML = generateJSONTree(jsonData);
You'd have this:
<json-tree id="json-tree"></json-tree>
...
const container = document.getElementById('json-tree');
container.jsonTree = jsonData;
Attributes not necessary, simply pass the json data as a prop. Granted, the difference isn't that big, but this is where web components shine.