Module: Dommy
- Defined in:
- lib/dommy/window.rb,
lib/dommy.rb,
lib/dommy/css.rb,
lib/dommy/url.rb,
lib/dommy/attr.rb,
lib/dommy/blob.rb,
lib/dommy/node.rb,
lib/dommy/event.rb,
lib/dommy/fetch.rb,
lib/dommy/range.rb,
lib/dommy/bridge.rb,
lib/dommy/crypto.rb,
lib/dommy/parser.rb,
lib/dommy/screen.rb,
lib/dommy/worker.rb,
lib/dommy/backend.rb,
lib/dommy/browser.rb,
lib/dommy/element.rb,
lib/dommy/history.rb,
lib/dommy/promise.rb,
lib/dommy/storage.rb,
lib/dommy/streams.rb,
lib/dommy/version.rb,
lib/dommy/data_uri.rb,
lib/dommy/document.rb,
lib/dommy/location.rb,
lib/dommy/animation.rb,
lib/dommy/form_data.rb,
lib/dommy/navigator.rb,
lib/dommy/resources.rb,
lib/dommy/scheduler.rb,
lib/dommy/dom_parser.rb,
lib/dommy/js/runtime.rb,
lib/dommy/navigation.rb,
lib/dommy/text_codec.rb,
lib/dommy/web_socket.rb,
lib/dommy/file_reader.rb,
lib/dommy/interaction.rb,
lib/dommy/performance.rb,
lib/dommy/shadow_root.rb,
lib/dommy/tree_walker.rb,
lib/dommy/url_pattern.rb,
lib/dommy/cookie_store.rb,
lib/dommy/event_source.rb,
lib/dommy/js/wire_tags.rb,
lib/dommy/notification.rb,
lib/dommy/svg_elements.rb,
lib/dommy/test_helpers.rb,
lib/dommy/data_transfer.rb,
lib/dommy/dom_exception.rb,
lib/dommy/html_elements.rb,
lib/dommy/html_elements.rb,
lib/dommy/internal/idna.rb,
lib/dommy/js/import_map.rb,
lib/dommy/js/marshaller.rb,
lib/dommy/bridge/methods.rb,
lib/dommy/js/host_bridge.rb,
lib/dommy/js/script_boot.rb,
lib/dommy/rspec/matchers.rb,
lib/dommy/custom_elements.rb,
lib/dommy/html_collection.rb,
lib/dommy/js/handle_table.rb,
lib/dommy/message_channel.rb,
lib/dommy/resize_observer.rb,
lib/dommy/callable_invoker.rb,
lib/dommy/js/module_loader.rb,
lib/dommy/media_query_list.rb,
lib/dommy/xml_http_request.rb,
lib/dommy/deferred_response.rb,
lib/dommy/interaction/debug.rb,
lib/dommy/internal/css/calc.rb,
lib/dommy/internal/punycode.rb,
lib/dommy/js/dom_interfaces.rb,
lib/dommy/mutation_observer.rb,
lib/dommy/interaction/driver.rb,
lib/dommy/internal/aria_role.rb,
lib/dommy/internal/css/color.rb,
lib/dommy/internal/idna_data.rb,
lib/dommy/compression_streams.rb,
lib/dommy/html_canvas_element.rb,
lib/dommy/interaction/locator.rb,
lib/dommy/internal/aria_state.rb,
lib/dommy/internal/child_node.rb,
lib/dommy/internal/cookie_jar.rb,
lib/dommy/internal/css/parser.rb,
lib/dommy/internal/namespaces.rb,
lib/dommy/internal/url_parser.rb,
lib/dommy/minitest/assertions.rb,
lib/dommy/internal/css/cascade.rb,
lib/dommy/internal/ipv4_parser.rb,
lib/dommy/internal/parent_node.rb,
lib/dommy/performance_observer.rb,
lib/dommy/internal/css/counters.rb,
lib/dommy/internal/css/supports.rb,
lib/dommy/internal/dom_matching.rb,
lib/dommy/internal/selector_ast.rb,
lib/dommy/intersection_observer.rb,
lib/dommy/js/bridge_conformance.rb,
lib/dommy/backend/makiri_adapter.rb,
lib/dommy/interaction/role_query.rb,
lib/dommy/internal/aria_snapshot.rb,
lib/dommy/internal/css_rule_text.rb,
lib/dommy/internal/node_equality.rb,
lib/dommy/interaction/dom_summary.rb,
lib/dommy/internal/css/rule_index.rb,
lib/dommy/internal/node_traversal.rb,
lib/dommy/internal/selector_index.rb,
lib/dommy/js/constructor_resolver.rb,
lib/dommy/internal/accessible_name.rb,
lib/dommy/internal/css/media_query.rb,
lib/dommy/internal/selector_parser.rb,
lib/dommy/js/custom_element_bridge.rb,
lib/dommy/internal/element_matching.rb,
lib/dommy/internal/global_functions.rb,
lib/dommy/internal/observer_manager.rb,
lib/dommy/internal/observer_matcher.rb,
lib/dommy/internal/scope_resolution.rb,
lib/dommy/internal/selector_matcher.rb,
lib/dommy/rspec/capy_style_matchers.rb,
lib/dommy/internal/css/ua_stylesheet.rb,
lib/dommy/internal/xml_serialization.rb,
lib/dommy/bridge/constructor_registry.rb,
lib/dommy/interaction/event_synthesis.rb,
lib/dommy/interaction/form_submission.rb,
lib/dommy/internal/accessibility_tree.rb,
lib/dommy/internal/node_wrapper_cache.rb,
lib/dommy/interaction/field_interactor.rb,
lib/dommy/internal/css_pseudo_handlers.rb,
lib/dommy/internal/observable_callback.rb,
lib/dommy/internal/mutation_coordinator.rb,
lib/dommy/internal/reflected_attributes.rb,
lib/dommy/internal/shadow_root_registry.rb,
lib/dommy/internal/css/custom_properties.rb,
lib/dommy/internal/css/property_registry.rb,
lib/dommy/internal/range_text_serializer.rb,
lib/dommy/internal/accessible_description.rb,
lib/dommy/internal/template_content_registry.rb,
lib/dommy/internal/css/computed_style_declaration.rb
Overview
Generated by script/build_idna_tables.rb from Unicode 16.0.0 source files in vendor/unicode/. Re-run after upgrading.
Tables are sorted, non-overlapping [start, end, value...] rows.
IDNAData.lookup(table, cp) does a binary search and returns
the matching row (or nil).
Defined Under Namespace
Modules: Backend, Bridge, CallableInvoker, DataUri, EventTarget, HyperlinkActivation, Interaction, Internal, Js, Minitest, Navigation, Node, NodeFilter, Parser, RSpec, Resources, SubmitButtonActivation, TestHelpers, TreeTraversalCore, WindowReflectingHandlers Classes: AbortController, AbortSignal, Animation, Attr, BatteryManager, BeforeUnloadEvent, Blob, BroadcastChannel, Browser, CDATASectionNode, CSSNamespace, CSSRule, CSSRuleList, CSSStyleSheet, CanvasGradient, CanvasRenderingContext2D, CharacterDataNode, ClassList, Clipboard, ClipboardEvent, CloseEvent, CommentNode, CompositionEvent, CompressionStream, CookieChangeEvent, CookieStore, Crypto, CryptoKey, CustomElementRegistry, CustomEvent, DOMException, DOMImplementation, DOMParser, DOMRect, DataTransfer, DatasetMap, DecompressionStream, DeferredResponse, Document, DocumentType, DragEvent, Element, ErrorEvent, ErrorValue, Event, EventSource, FetchFn, File, FileList, FileReader, FocusEvent, FormData, Fragment, Geolocation, HTMLAnchorElement, HTMLAreaElement, HTMLAudioElement, HTMLBRElement, HTMLBaseElement, HTMLBodyElement, HTMLButtonElement, HTMLCanvasElement, HTMLCollection, HTMLDListElement, HTMLDataElement, HTMLDataListElement, HTMLDetailsElement, HTMLDialogElement, HTMLDirectoryElement, HTMLDivElement, HTMLElement, HTMLEmbedElement, HTMLFieldSetElement, HTMLFontElement, HTMLFormControlsCollection, HTMLFormElement, HTMLFrameElement, HTMLFrameSetElement, HTMLHRElement, HTMLHeadElement, HTMLHeadingElement, HTMLHtmlElement, HTMLIFrameElement, HTMLImageElement, HTMLInputElement, HTMLLIElement, HTMLLabelElement, HTMLLegendElement, HTMLLinkElement, HTMLMapElement, HTMLMediaElement, HTMLMetaElement, HTMLMeterElement, HTMLModElement, HTMLOListElement, HTMLObjectElement, HTMLOptGroupElement, HTMLOptionElement, HTMLOptionsCollection, HTMLOutputElement, HTMLParagraphElement, HTMLParamElement, HTMLPictureElement, HTMLPreElement, HTMLProgressElement, HTMLQuoteElement, HTMLScriptElement, HTMLSelectElement, HTMLSlotElement, HTMLSourceElement, HTMLSpanElement, HTMLStyleElement, HTMLTableCaptionElement, HTMLTableCellElement, HTMLTableColElement, HTMLTableElement, HTMLTableRowElement, HTMLTableSectionElement, HTMLTemplateElement, HTMLTextAreaElement, HTMLTimeElement, HTMLTitleElement, HTMLTrackElement, HTMLUListElement, HTMLUnknownElement, HTMLVideoElement, HashChangeEvent, Headers, History, ImageData, InputEvent, IntersectionObserver, KeyboardEvent, KeyframeEffect, LiveNodeList, Location, Lock, LockManager, MediaList, MediaQueryList, MediaQueryListEvent, MessageChannel, MessageEvent, MessagePort, MouseEvent, MutationObserver, MutationRecord, NamedNodeMap, Navigator, NodeIterator, NodeList, Notification, Performance, PerformanceEntry, PerformanceObserver, PermissionStatus, Permissions, PointerEvent, PopStateEvent, ProcessingInstructionNode, ProgressEvent, PromiseRejectionEvent, PromiseValue, RadioNodeList, Range, ReadableStream, ReadableStreamDefaultController, ReadableStreamDefaultReader, Request, ResizeObserver, Response, RuleStyleDeclaration, SVGAElement, SVGAnimateElement, SVGAnimateMotionElement, SVGAnimateTransformElement, SVGAnimationElement, SVGCircleElement, SVGClipPathElement, SVGComponentTransferFunctionElement, SVGDefsElement, SVGDescElement, SVGDiscardElement, SVGElement, SVGEllipseElement, SVGFEBlendElement, SVGFEColorMatrixElement, SVGFEComponentTransferElement, SVGFECompositeElement, SVGFEConvolveMatrixElement, SVGFEDiffuseLightingElement, SVGFEDisplacementMapElement, SVGFEDistantLightElement, SVGFEDropShadowElement, SVGFEFloodElement, SVGFEFuncAElement, SVGFEFuncBElement, SVGFEFuncGElement, SVGFEFuncRElement, SVGFEGaussianBlurElement, SVGFEImageElement, SVGFEMergeElement, SVGFEMergeNodeElement, SVGFEMorphologyElement, SVGFEOffsetElement, SVGFEPointLightElement, SVGFESpecularLightingElement, SVGFESpotLightElement, SVGFETileElement, SVGFETurbulenceElement, SVGFilterElement, SVGFilterPrimitiveElement, SVGForeignObjectElement, SVGGElement, SVGImageElement, SVGLineElement, SVGLinearGradientElement, SVGMPathElement, SVGMarkerElement, SVGMaskElement, SVGMetadataElement, SVGPathElement, SVGPatternElement, SVGPolygonElement, SVGPolylineElement, SVGRadialGradientElement, SVGRectElement, SVGSVGElement, SVGSetElement, SVGStopElement, SVGSwitchElement, SVGSymbolElement, SVGTSpanElement, SVGTextElement, SVGTextPathElement, SVGTitleElement, SVGUseElement, SVGViewElement, Scheduler, Screen, ScreenOrientation, Selection, ShadowRoot, StandaloneEventTarget, Storage, StorageManager, StyleDeclaration, SubmitEvent, SubtleCrypto, TextDecoder, TextDecoderStream, TextEncoder, TextEncoderStream, TextMetrics, TextNode, ToggleEvent, Touch, TouchEvent, TouchList, TransformStream, TransformStreamDefaultController, TreeWalker, UIEvent, URL, URLPattern, URLSearchParams, ValidityState, ViewTransition, WakeLock, WakeLockSentinel, WebSocket, WheelEvent, Window, Worker, WritableStream, WritableStreamDefaultWriter, XMLHttpRequest, XMLHttpRequestUpload, XMLSerializer
Constant Summary collapse
- VERSION =
"0.10.0"- SVG_ELEMENT_CLASSES =
Tag-name → class lookup. Keys are the lowercased form Nokogiri::HTML5 stores in the tree. Tags absent from this table fall through to
Dommy::SVGElementviaelement_class_for. { "svg" => SVGSVGElement, "g" => SVGGElement, "circle" => SVGCircleElement, "rect" => SVGRectElement, "ellipse" => SVGEllipseElement, "line" => SVGLineElement, "polygon" => SVGPolygonElement, "polyline" => SVGPolylineElement, "path" => SVGPathElement, "text" => SVGTextElement, "tspan" => SVGTSpanElement, "defs" => SVGDefsElement, "use" => SVGUseElement, "image" => SVGImageElement, "symbol" => SVGSymbolElement, "foreignobject" => SVGForeignObjectElement, "title" => SVGTitleElement, "desc" => SVGDescElement, "mask" => SVGMaskElement, "clippath" => SVGClipPathElement, "pattern" => SVGPatternElement, "lineargradient" => SVGLinearGradientElement, "radialgradient" => SVGRadialGradientElement, "stop" => SVGStopElement, "filter" => SVGFilterElement, "marker" => SVGMarkerElement, # Recommended additions "a" => SVGAElement, "textpath" => SVGTextPathElement, "view" => SVGViewElement, "switch" => SVGSwitchElement, "metadata" => SVGMetadataElement, # Filter primitives (common ones) "fegaussianblur" => SVGFEGaussianBlurElement, "feoffset" => SVGFEOffsetElement, "feblend" => SVGFEBlendElement, "fecolormatrix" => SVGFEColorMatrixElement, "feflood" => SVGFEFloodElement, "fecomposite" => SVGFECompositeElement, "femerge" => SVGFEMergeElement, "femergenode" => SVGFEMergeNodeElement, "fecomponenttransfer" => SVGFEComponentTransferElement, "fefuncr" => SVGFEFuncRElement, "fefuncg" => SVGFEFuncGElement, "fefuncb" => SVGFEFuncBElement, "fefunca" => SVGFEFuncAElement, "fetile" => SVGFETileElement, "femorphology" => SVGFEMorphologyElement, "feimage" => SVGFEImageElement, "fedropshadow" => SVGFEDropShadowElement, "feturbulence" => SVGFETurbulenceElement, "fedisplacementmap" => SVGFEDisplacementMapElement, "fedistantlight" => SVGFEDistantLightElement, "fepointlight" => SVGFEPointLightElement, "fespotlight" => SVGFESpotLightElement, "feconvolvematrix" => SVGFEConvolveMatrixElement, "fediffuselighting" => SVGFEDiffuseLightingElement, "fespecularlighting" => SVGFESpecularLightingElement, # SMIL animation "animate" => SVGAnimateElement, "animatetransform" => SVGAnimateTransformElement, "animatemotion" => SVGAnimateMotionElement, "set" => SVGSetElement, "mpath" => SVGMPathElement, "discard" => SVGDiscardElement }.freeze
- HTML_ELEMENT_CLASSES =
Look up the subclass for a given HTML tag. Document#wrap_node consults this map; defaults to plain Element.
{ "a" => HTMLAnchorElement, "form" => HTMLFormElement, "input" => HTMLInputElement, "button" => HTMLButtonElement, "img" => HTMLImageElement, "canvas" => HTMLCanvasElement, "script" => HTMLScriptElement, "link" => HTMLLinkElement, "select" => HTMLSelectElement, "option" => HTMLOptionElement, "optgroup" => HTMLOptGroupElement, "textarea" => HTMLTextAreaElement, "label" => HTMLLabelElement, "fieldset" => HTMLFieldSetElement, "output" => HTMLOutputElement, "legend" => HTMLLegendElement, "slot" => HTMLSlotElement, "table" => HTMLTableElement, "thead" => HTMLTableSectionElement, "tbody" => HTMLTableSectionElement, "tfoot" => HTMLTableSectionElement, "tr" => HTMLTableRowElement, "td" => HTMLTableCellElement, "th" => HTMLTableCellElement, "caption" => HTMLTableCaptionElement, "dialog" => HTMLDialogElement, "details" => HTMLDetailsElement, "meter" => HTMLMeterElement, "progress" => HTMLProgressElement, "template" => HTMLTemplateElement, "audio" => HTMLAudioElement, "video" => HTMLVideoElement, "source" => HTMLSourceElement, "track" => HTMLTrackElement, "iframe" => HTMLIFrameElement, "picture" => HTMLPictureElement, "ol" => HTMLOListElement, "ul" => HTMLUListElement, "li" => HTMLLIElement, "time" => HTMLTimeElement, "data" => HTMLDataElement, "area" => HTMLAreaElement, "map" => HTMLMapElement, "object" => HTMLObjectElement, "embed" => HTMLEmbedElement, "base" => HTMLBaseElement, "meta" => HTMLMetaElement, "style" => HTMLStyleElement, "title" => HTMLTitleElement, "q" => HTMLQuoteElement, "blockquote" => HTMLQuoteElement, "ins" => HTMLModElement, "del" => HTMLModElement, "div" => HTMLDivElement, "span" => HTMLSpanElement, "p" => HTMLParagraphElement, "h1" => HTMLHeadingElement, "h2" => HTMLHeadingElement, "h3" => HTMLHeadingElement, "h4" => HTMLHeadingElement, "h5" => HTMLHeadingElement, "h6" => HTMLHeadingElement, "br" => HTMLBRElement, "hr" => HTMLHRElement, "pre" => HTMLPreElement, "body" => HTMLBodyElement, "head" => HTMLHeadElement, "html" => HTMLHtmlElement, "col" => HTMLTableColElement, "colgroup" => HTMLTableColElement, "datalist" => HTMLDataListElement, "dir" => HTMLDirectoryElement, "dl" => HTMLDListElement, "font" => HTMLFontElement, "frame" => HTMLFrameElement, "frameset" => HTMLFrameSetElement, "param" => HTMLParamElement }.freeze
- SVG_NAMESPACE_URI =
"http://www.w3.org/2000/svg"- HTML_NAMESPACE_URI =
"http://www.w3.org/1999/xhtml"
Class Method Summary collapse
-
.backend ⇒ Object
Convenience accessor:
Dommy.backend/Dommy.backend=. - .backend=(new_backend) ⇒ Object
-
.element_class_for(tag_name, namespace_uri = nil) ⇒ Object
Map a (local name, namespace) pair to its DOM interface class.
-
.new_window ⇒ Object
Build a fresh, empty Window (no host).
-
.parse(html) ⇒ Object
Parse an HTML string and return a fresh
Window. -
.structured_clone(value, memo = {}) ⇒ Object
structuredClone(value)— deep clone for plain Ruby values and DOM nodes (viacloneNode(true)). -
.structuredClone(value) ⇒ Object
JS-style global alias for symmetry with
window.structuredClone(...).
Class Method Details
.backend ⇒ Object
Convenience accessor: Dommy.backend / Dommy.backend=.
130 131 132 |
# File 'lib/dommy.rb', line 130 def self.backend Backend.current end |
.backend=(new_backend) ⇒ Object
134 135 136 |
# File 'lib/dommy.rb', line 134 def self.backend=(new_backend) Backend.current = new_backend end |
.element_class_for(tag_name, namespace_uri = nil) ⇒ Object
Map a (local name, namespace) pair to its DOM interface class. HTML-namespace names match case-SENSITIVELY (createElement lower-cases first, but createElementNS preserves case, so "SPAN" is unknown); any namespace other than HTML/SVG — including the null namespace — gets the generic Element.
4776 4777 4778 4779 4780 4781 4782 4783 4784 4785 4786 |
# File 'lib/dommy/html_elements.rb', line 4776 def self.element_class_for(tag_name, namespace_uri = nil) name = tag_name.to_s case namespace_uri when SVG_NAMESPACE_URI SVG_ELEMENT_CLASSES[name.downcase] || SVGElement when HTML_NAMESPACE_URI HTML_ELEMENT_CLASSES[name] || HTMLUnknownElement else Element end end |
.new_window ⇒ Object
Build a fresh, empty Window (no host). Equivalent to opening a blank document.
140 141 142 |
# File 'lib/dommy.rb', line 140 def self.new_window Window.new end |
.parse(html) ⇒ Object
Parse an HTML string and return a fresh Window.
When the input starts with <!doctype or <html>, it is parsed as
a full HTML document (preserving
The Window has no host (standalone CRuby usage); embedders that need bridge callbacks (e.g. a wasm host) pass a host instead.
118 119 120 121 122 123 124 125 126 127 |
# File 'lib/dommy.rb', line 118 def self.parse(html) s = html.to_s if s.match?(/\A\s*(<!doctype|<html\b)/i) Window.new(nil, backend_doc: Backend.parse(s)) else window = Window.new window.document.body.inner_html = s window end end |
.structured_clone(value, memo = {}) ⇒ Object
structuredClone(value) — deep clone for plain Ruby values and
DOM nodes (via cloneNode(true)). Mirrors the JS structured-clone
algorithm for the subset we support:
- primitives (String / Numeric / Boolean / nil) → copied
- Array / Hash / Set → deep-cloned
- DOM nodes (anything responding to `clone_node`) → deep-cloned
- cyclic structures → preserved
- Proc / Method / Class / Module / IO → DataCloneError
Symbols are passed through unchanged (Ruby has no Symbol clone
concept; JS treats Symbols as DataCloneError, but Ruby code uses
them as hash keys so this is the pragmatic choice).
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 |
# File 'lib/dommy.rb', line 157 def self.structured_clone(value, memo = {}) return memo[value.object_id] if memo.key?(value.object_id) case value when nil, true, false, Numeric, Symbol value when String value.dup when Array arr = [] memo[value.object_id] = arr value.each { |v| arr << structured_clone(v, memo) } arr when Hash h = {} memo[value.object_id] = h value.each { |k, v| h[structured_clone(k, memo)] = structured_clone(v, memo) } h when Set s = Set.new memo[value.object_id] = s value.each { |v| s << structured_clone(v, memo) } s when Time value.dup when Regexp value.dup when Proc, Method, UnboundMethod, IO, Class, Module raise DOMException::DataCloneError, "#{value.class} cannot be cloned" else if value.respond_to?(:clone_node) value.clone_node(true) else # Fallback: rely on the object's own `dup` (which handles # custom classes the user might pass through). value.dup end end end |
.structuredClone(value) ⇒ Object
JS-style global alias for symmetry with window.structuredClone(...).
199 200 201 |
# File 'lib/dommy.rb', line 199 def Dommy.structuredClone(value) structured_clone(value) end |