Class: Dommy::Document
- Inherits:
-
Object
- Object
- Dommy::Document
- Includes:
- Bridge::Methods, EventTarget, Node
- Defined in:
- lib/dommy/document.rb
Overview
document — the entry point for DOM construction and querying.
Wrapper caching keeps DOM identity stable across repeated
traversals (body.children[0].parentElement).
Constant Summary collapse
- SELECTOR_INDEX_MIN_REUSE =
A by-id/class/tag index of the backend element tree, memoized per DOM generation, for SelectorMatcher's document-scoped fast path (or nil to tell the caller to walk). Rebuilt lazily only after a mutation bumps style_generation, so it costs one tree walk per generation and pays off when several queries run before the next mutation.
Adaptive bypass: if the index keeps getting invalidated after serving only a handful of queries (a mutation-between-every-query workload, where building it never pays back), stop building it and just walk — re-testing periodically. This keeps the worst case at walk speed rather than the ~15% regression an always-on index would add.
3- SELECTOR_INDEX_LOW_RUN_LIMIT =
queries an index must serve to have paid for its build
8- SELECTOR_INDEX_RETEST_GAP =
consecutive low-reuse generations before bypassing
64- SCOPED_QUERY_CACHE_CAP =
An element-scoped querySelector(All) result cache (the document-rooted one lives in NodeWrapperCache). jQuery
$(el).find(sel)re-queries the same (element, selector) constantly between mutations; this memoizes the match set, keyed by [scope object_id, kind, selector] and tagged with the DOM generation, so a hit skips the whole combinator match. Capped, and a mutation (style_generation bump) makes every entry stale at once. 4096
Constants included from Node
Node::ATTRIBUTE_NODE, Node::CDATA_SECTION_NODE, Node::COMMENT_NODE, Node::DOCUMENT_FRAGMENT_NODE, Node::DOCUMENT_NODE, Node::DOCUMENT_POSITION_CONTAINED_BY, Node::DOCUMENT_POSITION_CONTAINS, Node::DOCUMENT_POSITION_DISCONNECTED, Node::DOCUMENT_POSITION_FOLLOWING, Node::DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC, Node::DOCUMENT_POSITION_PRECEDING, Node::DOCUMENT_TYPE_NODE, Node::ELEMENT_NODE, Node::HTML_NAMESPACE, Node::PROCESSING_INSTRUCTION_NODE, Node::TEXT_NODE, Node::XMLNS_NAMESPACE, Node::XML_NAMESPACE
Instance Attribute Summary collapse
-
#__css_style_cache__ ⇒ Object
--- CSS cascade support (Internal::CSS) --- Monotonic counter bumped on every DOM mutation; the CSS layer invalidates its per-document style cache wholesale when it moves.
-
#backend_doc ⇒ Object
readonly
Returns the value of attribute backend_doc.
-
#content_type ⇒ Object
content_type defaults to "text/html"; settable so an integration layer can reflect the response Content-Type.
-
#css_import_resolver ⇒ Object
A host-supplied
->(url) { css_text_or_nil }resolving @import URLs to CSS (Dommy has no network of its own — same idea as filling). -
#default_view ⇒ Object
Returns the value of attribute default_view.
-
#external_script_runner ⇒ Object
A
->(element, src) {}set by the integration layer to fetch + execute a classic<script src>that's dynamically inserted into the document (e.g. webpack/Vite loading an on-demand chunk via document.head.appendChild). -
#fullscreen_element ⇒ Object
readonly
Fullscreen API — no actual fullscreen mode, just track which element claimed it.
-
#script_runner ⇒ Object
A
->(source_text) {}set by the JS layer to execute a classic