Project

General

Profile

Feature #9940

array syntax for referencing parent, child or sibling nodes

Added by Greg Shah about 1 year ago. Updated about 1 year ago.

Status:
New
Priority:
Normal
Assignee:
-
Target version:
-
Start date:
Due date:
% Done:

0%

billable:
No
vendor_id:
GCD
case_num:
version_reported:
version_resolved:
reviewer:
production:
No
env_name:
topics:

History

#1 Updated by Greg Shah about 1 year ago

  • Subject changed from array syntax for referencing parent or child nodes to array syntax for referencing parent, child or sibling nodes

It is common to use chaining to reference parent nodes. Instead of copy.parent.parent.parent or copy.getAncestor(3) we could provide syntax like copy.parent[2] for "upward access".

Child nodes are often referenced using node.getChildAt(x) but we could provide access to children via node.child[x].

Sibling nodes might also benefit from this idea. Instead of node.nextSibling.nextSibling it could be node.sibling[1].

The only slightly inconsistent part here is that parent access would be "vertical" and the sibling/child access would be "horizontal".

Also available in: Atom PDF