Guest User

Untitled

a guest
Dec 4th, 2015
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. let doc = new Tree([
  2. new Rule('.example', [
  3. new Property('width', new Value(1, 'px')),
  4. new Property('height', new Value(2, 'px')),
  5. ])
  6. ]);
  7.  
  8. // Select the "width" property out of the rule.
  9. let child = doc.children[0].children[0];
  10.  
  11. // From "child", how do we get back to the rule?
  12. // This normally would be impossible in JavaScript.
  13. // But with the `Tree` initialization, we can use
  14. // .parent to get a reference back to the parent.
  15. let parent = child.parent;
  16.  
  17. console.log(parent.name);
  18. // -> ".example"
Advertisement
Add Comment
Please, Sign In to add comment