Module: Dommy::Internal::ObserverMatcher
- Defined in:
- lib/dommy/internal/observer_matcher.rb
Overview
Matches a mutation target against an observed node based on observer options. Works exclusively with wrapped DOM nodes (not Nokogiri internals).
Class Method Summary collapse
-
.matches?(observed_wrapped, target_wrapped, subtree:) ⇒ Boolean
Does this observer's target scope match the mutation target? Returns true if: - target == observed (exact match), OR - subtree=true AND target is descendant of observed.
-
.matches_document?(_target_wrapped, subtree:) ⇒ Boolean
Special case: Document observation.
Class Method Details
.matches?(observed_wrapped, target_wrapped, subtree:) ⇒ Boolean
Does this observer's target scope match the mutation target? Returns true if:
- target == observed (exact match), OR
- subtree=true AND target is descendant of observed
14 15 16 17 18 19 20 |
# File 'lib/dommy/internal/observer_matcher.rb', line 14 def matches?(observed_wrapped, target_wrapped, subtree:) return true if target_wrapped.equal?(observed_wrapped) return false unless subtree return false unless observed_wrapped.respond_to?(:contains?) observed_wrapped.contains?(target_wrapped) end |
.matches_document?(_target_wrapped, subtree:) ⇒ Boolean
Special case: Document observation. Matches iff subtree=true (a plain target==observed match never applies to a Document).
24 25 26 |
# File 'lib/dommy/internal/observer_matcher.rb', line 24 def matches_document?(_target_wrapped, subtree:) subtree end |