Problems

Event Bubbling Path

EasyDOM & Events

The DOM tree is given as nested JSON: {"id": string, "children": [...]}. Given a target id, print the bubbling path from the target up to the root, ids separated by >.

Input: line 1 — tree JSON; line 2 — target id. Output: path like button > form > body.

Your program reads from stdin and prints to stdout.

Example 1

Input: {"id":"body","children":[{"id":"form","children":[{"id":"button","children":[]}]}]} button

Output: button > form > body

Hints

JavaScriptDOMEvents