-
Notifications
You must be signed in to change notification settings - Fork 0
Selector Parsing
CamiloMM edited this page Jun 14, 2013
·
2 revisions
Parsing selectors is what graphene does. How it does it? Here we find out.
Selectors can be grouped. This means that we split a selector by commas:
.first part, #second .part, third:part
Then we trim each separate part. After parsing each selector in the group, arrays are produced; these will be merged and unique'd.
Each selector is a world on its own.
They generally follow a parent-child relationship. So you can read them as:
.theNode
.ancestor .theNode
.ancestor .parent > .theNode
The browsers read selectors right-to-left, they do this because looking at a node, they want to figure out which selectors match it (when going over a tree, this makes sense). Instead, we read them left-to-right.
In the complex selectors sandbox, we see what would be ideal javascript code to run complicated selectors.