| 128 | } |
| 129 | |
| 130 | testCSSConditions(conds) { |
| 131 | const pseudoCheck = text => { |
| 132 | switch (text) { |
| 133 | case 'root': |
| 134 | return this.tagName === 'html'; |
| 135 | |
| 136 | case 'link': // we have no history recorded (yet) |
| 137 | case 'any-link': |
| 138 | return this.tagName === 'a' && !!this.attrs.href; |
| 139 | } |
| 140 | |
| 141 | return false; |
| 142 | }; |
| 143 | |
| 144 | for (const x of conds) { // a#b.c (a AND b AND c) |
| 145 | if ( |
| 146 | !(x.type === SelectorType.Tag && this.tagName === x.text) && // tag |
| 147 | !(x.type === SelectorType.Id && this.id === x.text) && // id |
| 148 | !(x.type === SelectorType.Class && this.hasClass(x.text)) && // class |
| 149 | !(x.type === SelectorType.Pseudo && pseudoCheck(x.text)) && // pseudo classes |
| 150 | !(x.type === SelectorType.Universal) // universal (*) |
| 151 | ) return false; |
| 152 | } |
| 153 | |
| 154 | return true; |
| 155 | } |
| 156 | |
| 157 | // selectors (a, b, c) |
| 158 | // combinators (a b > c) |