Class: Dommy::Document

Inherits:
Object
  • Object
show all
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