(&self, query: &VisitNode)
| 45 | } |
| 46 | |
| 47 | fn build_display(&self, query: &VisitNode) -> String { |
| 48 | let meta = query.self_metadata(); |
| 49 | let meta = &meta; |
| 50 | let mut display = query.node_id.expect("tree output only displays queryable nodes").tag_name().to_string(); |
| 51 | |
| 52 | // Attributes |
| 53 | for &kind in PROPERTY_KIND_VARIANTS { |
| 54 | if !meta.property_kinds.contains(kind) { |
| 55 | continue; |
| 56 | } |
| 57 | if let Some(cursor) = query.property(kind) { |
| 58 | let value = self.cursor_to_str(cursor); |
| 59 | let attr_name = match kind { |
| 60 | PropertyKind::Name => "name", |
| 61 | _ => continue, |
| 62 | }; |
| 63 | display.push_str(&format!("[{}={}]", attr_name, value)); |
| 64 | } |
| 65 | } |
| 66 | |
| 67 | // Pseudos |
| 68 | for name in QueryPseudoClass::matching_metadata_pseudos(meta) { |
| 69 | display.push(':'); |
| 70 | display.push_str(name); |
| 71 | } |
| 72 | if let Some(size) = QueryFunctionalPseudoClass::matching_size(meta) { |
| 73 | display.push_str(&format!(":size({})", size)); |
| 74 | } |
| 75 | |
| 76 | display |
| 77 | } |
| 78 | |
| 79 | fn cursor_to_str(&self, cursor: Cursor) -> &str { |
| 80 | let span = cursor.to_span(); |
no test coverage detected