parseIDSelector parses a selector that matches by id attribute.
()
| 291 | |
| 292 | // parseIDSelector parses a selector that matches by id attribute. |
| 293 | func (p *parser) parseIDSelector() (Selector, error) { |
| 294 | if p.i >= len(p.s) { |
| 295 | return nil, fmt.Errorf("expected id selector (#id), found EOF instead") |
| 296 | } |
| 297 | if p.s[p.i] != '#' { |
| 298 | return nil, fmt.Errorf("expected id selector (#id), found '%c' instead", p.s[p.i]) |
| 299 | } |
| 300 | |
| 301 | p.i++ |
| 302 | id, err := p.parseName() |
| 303 | if err != nil { |
| 304 | return nil, err |
| 305 | } |
| 306 | |
| 307 | return attributeEqualsSelector("id", id), nil |
| 308 | } |
| 309 | |
| 310 | // parseClassSelector parses a selector that matches by class attribute. |
| 311 | func (p *parser) parseClassSelector() (Selector, error) { |
no test coverage detected