Module: Dommy::Bridge
- Defined in:
- lib/dommy/bridge.rb,
lib/dommy/bridge/methods.rb,
lib/dommy/bridge/constructor_registry.rb
Overview
Dommy::Bridge — adapter classes for JS-style bridges (wasm
embedders that route DOM method calls and constructor new ops
through the __js_get__ / __js_set__ / __js_call__ /
__js_new__ protocol).
CRuby users writing happy-dom-style tests can ignore everything in this namespace; it's only relevant when integrating Dommy with an external runtime (such as an mruby-on-wasm host) that constructs callbacks / events / promises via the bridge view.
The protocol contract:
- `__js_get__(name)` reads a JS-style property by string name
- `__js_set__(name, value)` writes one
- `__js_call__(method, args)` invokes a method with positional
args (Array)
- `__js_new__(args)` invokes the value as a JS constructor
Defined Under Namespace
Modules: Methods Classes: ArrayBuffer, Bytes, Callback, Constructor, ConstructorRegistry, JSValue, PromiseConstructor, PromiseSettler, RangeError, ThrowValue, TypeError
Constant Summary collapse
- UNHANDLED =
Sentinel returned by
__js_set__when a key is not a known DOM property (so the JS host can keep it as a JS-side expando, preserving identity) rather than silently dropping it. :__js_unhandled__- UNDEFINED =
Sentinel for the JS
undefinedvalue, used in both directions:- a `__js_call__` returns it for a void (undefined-returning) op, so the host marshals JS `undefined` rather than the `null` a bare Ruby `nil` would (e.g. DOMTokenList add/remove return undefined); - a top-level JS `undefined` *argument* arrives as it (whereas JS `null` arrives as `nil`), so WebIDL-style dispatch can tell an omitted optional argument from an explicit null.Its
to_sis "undefined" so a DOMString coercion of a stray undefined is still spec-faithful. Object.new
- ABSENT =
The sentinel a
__js_get__returns for a GENUINELY-ABSENT property (a key the object does not have), as distinct from a present property whose value isnil/JS null orUNDEFINED/JS undefined. It marshals to JSundefinedfor the value, but the proxy reports("x" in obj) === falsefor it — so feature detection likeisUndefined(window.Vue)AND"Vue" in windoware both correct. (UNDEFINED means present-but-undefined → reported present.) Object.new