Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let doc = new Tree([
- new Rule('.example', [
- new Property('width', new Value(1, 'px')),
- new Property('height', new Value(2, 'px')),
- ])
- ]);
- // Select the "width" property out of the rule.
- let child = doc.children[0].children[0];
- // From "child", how do we get back to the rule?
- // This normally would be impossible in JavaScript.
- // But with the `Tree` initialization, we can use
- // .parent to get a reference back to the parent.
- let parent = child.parent;
- console.log(parent.name);
- // -> ".example"
Advertisement
Add Comment
Please, Sign In to add comment