Skip to content
This repository was archived by the owner on Nov 27, 2018. It is now read-only.

Relationship Pattern

dhemery edited this page Apr 9, 2012 · 24 revisions

A relationship pattern is a sequence of subject patterns separated by combinators.

Relationship Pattern

Subjects. By default, the subjects of a relationship pattern are the subjects of the last subject pattern in the relationship pattern.

A subject pattern is any pattern that can be related by a combinator. There are two kinds of subject patterns: instance patterns and branch patterns.

Subject Pattern

Combinators

A combinator is punctuation that represents a relationship between two views. Whitespace may appear on either side of a combinator.

  • s1 s2descendant combinator — matches a view s2 that is a descendant of view s1. The combinator is the whitespace between s1 and s2.

  • s1>s2child combinator — matches a view s2 that is a subview of view s1.

  • s1~s2sibling combinator — matches a view s2 that has a sibling view s1.

A branch pattern is a relationship pattern enclosed in parentheses.

Branch Pattern

  • (s1 s2) — matches a view s1 that has a descendant view s2.

Subjects. A branch pattern's subjects are the subjects of the first subject pattern in the enclosed relationship pattern.

Clone this wiki locally