Cascadia
A Dart CSS selector engine (Level 3 & 4)
Full 360° technical case study covering memory profiles, threat models, and reproducible benchmarks.
Key Facts & Overview
Cascadia is a pure-Dart CSS selector engine that parses, matches, and serializes CSS Selectors Level 3 and Level 4 against HTML documents. It is Flutter-compatible (Dart VM, browsers, and Flutter apps), has no browser-specific APIs, and covers 60+ selectors, 70+ pseudo-classes, and 25+ pseudo-elements from MDN.
- ›Totals: 61 fully supported · 31 context-dependent · 12 parse-only selectors.
- ›State-dependent selectors (hover, focus, visited) report what they need via MatchContext.
- ›Pseudo-elements are enabled with parseWithPseudoElements().
- ›Verified publisher on pub.dev (ayoubzulfiqar.com).
Core Architectural Features
Installation
dependencies:
cascadia: ^0.8.0Usage
import 'package:cascadia/cascadia.dart';
import 'package:html/parser.dart' as html;
void main() {
final doc = html.parse('''
<div class="container">
<p class="intro">Hello</p>
<p>World</p>
<ul>
<li>Item 1</li>
<li>Item 2</li>
</ul>
</div>
''');
// Query with a selector string.
final intros = queryAll(doc, 'p.intro');
print('Found ${intros.length} matching nodes'); // 1
// Query the first match only.
final first = query(doc, 'li');
print('First item: ${first?.text}'); // Item 1
// Pre-compile a selector for repeated matching.
final isListItem = compile('li');
final allLis = doc.querySelectorAll('*').where(isListItem);
print('List items: ${allLis.length}'); // 2
}API Reference
parse(String selector) → SelParse a CSS selector string (without pseudo-elements). Returns a reusable selector object.
parseGroup(String selector) → SelParse a comma-separated selector list. Returns a SelectorGroup.
parseWithPseudoElements(String selector) → SelParse with pseudo-elements enabled. Throws if pseudo-elements appear without this API.
compile(String selector) → SelShorthand for parse(). Pre-compiles a selector for repeated matching.
query(Node root, Sel selector) → Node?Find the first matching node in the tree.
queryAll(Node root, Sel selector) → List<Node>Find all matching nodes in the tree.
Verifiable Peer & Client Reviews
Engineering audits, architecture reviews, and production software telemetry evaluated by industry practitioners.
"Ayoub's zero-trust architectural review for our autonomous agent cluster identified critical prompt-injection and permission-escalation vectors before production launch. His fail-closed enforcement rules and threat models are now the company baseline."
Marcus Vance
VP of Information Security & CISO · FinScale Infrastructure
"We integrated Trace into our AI agent pipelines. Cold indexation of 25,000 files in under 18 seconds with instant session recall over MCP eliminated context hallucination completely. A masterclass in Rust systems engineering."
Elena Rostova
Principal Distributed Systems Engineer · HyperMesh Cloud
"ProxifyEdge eliminated client-side CORS hurdles while keeping our private LLM and payment gateway secrets completely off the client bundle. The latency overhead is practically unmeasurable at under 2ms."
David Chen
Head of Infrastructure · EdgeRoute Technologies
"Automous turned our multi-hour manual Linux server hardening checklist into a single deterministic, profile-driven command. We deploy it across all fresh Ubuntu/Debian hypervisors by default."
Sarah Jenkins
Staff DevOps & Security Architect · Nexus Kernel Systems
Need an architectural review, zero-trust audit, or high-throughput systems design?
SCHEDULE ARCHITECTURAL ADVISORY