dommy 0.15.0 → 0.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/dommy/backend.rb +16 -15
- data/lib/dommy/blob.rb +17 -0
- data/lib/dommy/bridge/values.rb +29 -2
- data/lib/dommy/bridge/wire_tags.rb +8 -4
- data/lib/dommy/browser.rb +324 -49
- data/lib/dommy/character_data.rb +20 -27
- data/lib/dommy/class_list.rb +24 -9
- data/lib/dommy/cookie_jar.rb +408 -0
- data/lib/dommy/cookie_store.rb +104 -49
- data/lib/dommy/css.rb +34 -8
- data/lib/dommy/custom_elements.rb +362 -114
- data/lib/dommy/data_transfer.rb +22 -2
- data/lib/dommy/document.rb +1071 -200
- data/lib/dommy/dom_exception.rb +6 -0
- data/lib/dommy/dom_parser.rb +46 -14
- data/lib/dommy/dom_string_list.rb +36 -0
- data/lib/dommy/element.rb +217 -102
- data/lib/dommy/element_internals.rb +215 -0
- data/lib/dommy/encodings.rb +10 -0
- data/lib/dommy/event.rb +378 -122
- data/lib/dommy/event_source.rb +4 -30
- data/lib/dommy/file_reader.rb +5 -29
- data/lib/dommy/form_data.rb +40 -6
- data/lib/dommy/form_entry_list.rb +106 -137
- data/lib/dommy/fragment.rb +11 -10
- data/lib/dommy/history.rb +247 -90
- data/lib/dommy/html_canvas_element.rb +15 -35
- data/lib/dommy/html_collection.rb +49 -30
- data/lib/dommy/html_elements/base.rb +111 -69
- data/lib/dommy/html_elements/embedded.rb +349 -105
- data/lib/dommy/html_elements/forms/form.rb +407 -368
- data/lib/dommy/html_elements/forms/input.rb +333 -174
- data/lib/dommy/html_elements/forms/select.rb +90 -74
- data/lib/dommy/html_elements/interactive.rb +274 -64
- data/lib/dommy/html_elements/media.rb +71 -30
- data/lib/dommy/html_elements/metadata.rb +215 -71
- data/lib/dommy/html_elements/miscellaneous.rb +58 -14
- data/lib/dommy/html_elements/tables.rb +7 -9
- data/lib/dommy/html_elements.rb +23 -1
- data/lib/dommy/hyperlink_utils.rb +15 -4
- data/lib/dommy/interaction/drag_and_drop.rb +187 -0
- data/lib/dommy/interaction/event_synthesis.rb +182 -24
- data/lib/dommy/interaction/field_interactor.rb +17 -5
- data/lib/dommy/interaction/form_submission.rb +10 -4
- data/lib/dommy/interaction/key_sender.rb +101 -16
- data/lib/dommy/interaction.rb +1 -0
- data/lib/dommy/internal/accessibility_tree.rb +15 -3
- data/lib/dommy/internal/accessible_description.rb +1 -1
- data/lib/dommy/internal/accessible_name.rb +10 -17
- data/lib/dommy/internal/aria_role.rb +1 -1
- data/lib/dommy/internal/autofill.rb +2 -2
- data/lib/dommy/internal/backend_prefilter.rb +1 -5
- data/lib/dommy/internal/ce_reactions.rb +285 -0
- data/lib/dommy/internal/ce_reactions_table.rb +296 -0
- data/lib/dommy/internal/child_list.rb +7 -43
- data/lib/dommy/internal/child_navigable.rb +155 -0
- data/lib/dommy/internal/child_node.rb +44 -41
- data/lib/dommy/internal/close_watcher_manager.rb +238 -0
- data/lib/dommy/internal/complex_match.rb +3 -1
- data/lib/dommy/internal/constraint_validation.rb +130 -0
- data/lib/dommy/internal/css/ancestor_filter.rb +107 -0
- data/lib/dommy/internal/css/cascade.rb +7 -7
- data/lib/dommy/internal/css/cascaded_declarations.rb +4 -1
- data/lib/dommy/internal/css/computed_style_builder.rb +9 -3
- data/lib/dommy/internal/css/custom_properties.rb +41 -29
- data/lib/dommy/internal/css/parser.rb +0 -22
- data/lib/dommy/internal/css/renderability.rb +6 -0
- data/lib/dommy/internal/css/rule_index.rb +149 -98
- data/lib/dommy/internal/css/rule_index_inputs.rb +135 -0
- data/lib/dommy/internal/css/selector_dependencies.rb +8 -2
- data/lib/dommy/internal/css/style_cache.rb +7 -4
- data/lib/dommy/internal/css/ua_stylesheet.rb +34 -0
- data/lib/dommy/internal/declarative_shadow_roots.rb +182 -0
- data/lib/dommy/internal/document_generations.rb +55 -2
- data/lib/dommy/internal/document_interaction_state.rb +293 -9
- data/lib/dommy/internal/dom_matching.rb +2 -2
- data/lib/dommy/internal/element_aria.rb +25 -19
- data/lib/dommy/internal/element_popover.rb +226 -25
- data/lib/dommy/internal/element_shadow.rb +97 -26
- data/lib/dommy/internal/element_state.rb +98 -5
- data/lib/dommy/internal/element_top_layer.rb +15 -1
- data/lib/dommy/internal/enumerated_keyword_sets.rb +40 -0
- data/lib/dommy/internal/event_handler_tables.rb +241 -0
- data/lib/dommy/internal/event_handlers.rb +149 -0
- data/lib/dommy/internal/exception_report.rb +1 -1
- data/lib/dommy/internal/focusability.rb +267 -0
- data/lib/dommy/internal/form_associated_custom_elements.rb +127 -0
- data/lib/dommy/internal/html_or_svg_or_mathml_element.rb +34 -23
- data/lib/dommy/internal/html_serialization.rb +292 -0
- data/lib/dommy/internal/idl_reflection.rb +202 -0
- data/lib/dommy/internal/idl_reflection_table.rb +589 -0
- data/lib/dommy/internal/infra.rb +9 -0
- data/lib/dommy/internal/input_type.rb +76 -18
- data/lib/dommy/internal/insertion_point.rb +27 -3
- data/lib/dommy/internal/js_number.rb +60 -0
- data/lib/dommy/internal/light_dismiss.rb +178 -0
- data/lib/dommy/internal/mime_type.rb +8 -0
- data/lib/dommy/internal/mutation_coordinator.rb +94 -62
- data/lib/dommy/internal/node_adopter.rb +52 -4
- data/lib/dommy/internal/node_factory.rb +111 -7
- data/lib/dommy/internal/node_identity.rb +1 -1
- data/lib/dommy/internal/node_traversal.rb +22 -4
- data/lib/dommy/internal/node_wrapper_cache.rb +6 -38
- data/lib/dommy/internal/observer_options.rb +24 -14
- data/lib/dommy/internal/origin.rb +86 -0
- data/lib/dommy/internal/parent_node.rb +10 -8
- data/lib/dommy/internal/popover_invoker_element.rb +67 -0
- data/lib/dommy/internal/popover_stack.rb +120 -0
- data/lib/dommy/internal/post_insertion_steps.rb +140 -71
- data/lib/dommy/internal/reflected_attributes.rb +128 -18
- data/lib/dommy/internal/rendered_text/collector.rb +1 -5
- data/lib/dommy/internal/rendered_text/fragment.rb +6 -2
- data/lib/dommy/internal/selector_arguments.rb +2 -1
- data/lib/dommy/internal/selector_match.rb +1 -1
- data/lib/dommy/internal/selector_matcher.rb +11 -6
- data/lib/dommy/internal/selector_parser.rb +14 -1
- data/lib/dommy/internal/sequential_focus_navigation.rb +210 -0
- data/lib/dommy/internal/shadow_root_registry.rb +7 -0
- data/lib/dommy/internal/template_content_registry.rb +7 -1
- data/lib/dommy/internal/text_selection.rb +185 -32
- data/lib/dommy/internal/toggle_events.rb +6 -4
- data/lib/dommy/internal/unsafe_html.rb +107 -0
- data/lib/dommy/internal/url_parser.rb +84 -8
- data/lib/dommy/internal/user_activation.rb +192 -0
- data/lib/dommy/internal/web_idl.rb +149 -16
- data/lib/dommy/internal/window_constructors.rb +26 -6
- data/lib/dommy/internal/xml_serialization.rb +3 -3
- data/lib/dommy/js/constructor_resolver.rb +18 -0
- data/lib/dommy/js/custom_element_bridge.rb +57 -82
- data/lib/dommy/js/dom_interfaces.rb +50 -15
- data/lib/dommy/js/host_bridge.rb +189 -40
- data/lib/dommy/js/host_runtime.js +1897 -415
- data/lib/dommy/js/marshaller.rb +13 -4
- data/lib/dommy/js/module_loader.rb +37 -6
- data/lib/dommy/js/module_preload.rb +107 -29
- data/lib/dommy/js/script_boot.rb +197 -115
- data/lib/dommy/js/serialized_record.rb +32 -0
- data/lib/dommy/js/webidl_event_handlers.js +45 -0
- data/lib/dommy/js/webidl_members.js +196 -0
- data/lib/dommy/js/webidl_signatures.js +2055 -0
- data/lib/dommy/js/webidl_tables.js +47 -100
- data/lib/dommy/js/window_wiring.rb +9 -5
- data/lib/dommy/location.rb +129 -76
- data/lib/dommy/media_query_list.rb +4 -13
- data/lib/dommy/message_channel.rb +137 -64
- data/lib/dommy/mutation_observer.rb +2 -0
- data/lib/dommy/navigation.rb +59 -9
- data/lib/dommy/navigator.rb +131 -5
- data/lib/dommy/node.rb +19 -11
- data/lib/dommy/notification.rb +9 -1
- data/lib/dommy/promise.rb +8 -0
- data/lib/dommy/range.rb +5 -34
- data/lib/dommy/resources.rb +38 -3
- data/lib/dommy/scheduler.rb +176 -48
- data/lib/dommy/shadow_root.rb +117 -19
- data/lib/dommy/storage.rb +135 -25
- data/lib/dommy/structured_data.rb +45 -0
- data/lib/dommy/style_declaration.rb +16 -0
- data/lib/dommy/text_codec.rb +2 -14
- data/lib/dommy/tree_walker.rb +10 -18
- data/lib/dommy/url.rb +11 -4
- data/lib/dommy/validity_state.rb +109 -107
- data/lib/dommy/version.rb +1 -1
- data/lib/dommy/web_socket.rb +5 -28
- data/lib/dommy/window.rb +811 -99
- data/lib/dommy/worker.rb +4 -28
- data/lib/dommy/xml_http_request.rb +32 -45
- data/lib/dommy.rb +35 -1
- metadata +35 -4
- data/lib/dommy/internal/cookie_jar.rb +0 -29
|
@@ -3,8 +3,9 @@
|
|
|
3
3
|
// These are the enumerations the specs themselves make: which interfaces have a
|
|
4
4
|
// value iterator or a named getter, what [Constant]s an interface object
|
|
5
5
|
// carries, which members go on which interface prototype and with what `length`,
|
|
6
|
-
// which attributes are [LegacyUnforgeable] or readonly, which operations
|
|
7
|
-
// undefined
|
|
6
|
+
// which attributes are [LegacyUnforgeable] or readonly, and which operations
|
|
7
|
+
// return undefined. (Which `on*` attributes are event handlers is generated
|
|
8
|
+
// from the IDL, into webidl_event_handlers.js.) They describe the
|
|
8
9
|
// platform, not Dommy's bridge — they change when a spec changes, whereas
|
|
9
10
|
// host_runtime.js changes when the bridge's machinery does, which is why they
|
|
10
11
|
// are a file of their own. test/support/webidl_audit.rb reads the [Constant]
|
|
@@ -25,7 +26,9 @@ globalThis.__rbIdl = (function () {
|
|
|
25
26
|
const ARRAY_LIKE_COLLECTIONS = new Set([
|
|
26
27
|
"HTMLCollection", "HTMLFormControlsCollection", "HTMLOptionsCollection", "NodeList",
|
|
27
28
|
"RadioNodeList", "DOMTokenList", "NamedNodeMap", "DOMStringList", "FileList", "CSSRuleList",
|
|
28
|
-
"StyleSheetList", "DataTransferItemList", "MediaList", "HTMLSelectElement"
|
|
29
|
+
"StyleSheetList", "DataTransferItemList", "MediaList", "HTMLSelectElement",
|
|
30
|
+
// `getter Element (unsigned long index)` + `length`: form[i] is elements[i].
|
|
31
|
+
"HTMLFormElement"
|
|
29
32
|
]);
|
|
30
33
|
// Legacy platform objects with a WebIDL indexed property SETTER: `obj[i] = v`
|
|
31
34
|
// routes to the host (Ruby __js_set__ with the index) instead of being a
|
|
@@ -41,44 +44,6 @@ globalThis.__rbIdl = (function () {
|
|
|
41
44
|
// because being iterable is the exception, not the rule.
|
|
42
45
|
const PAIR_ITERABLE_COLLECTIONS = new Set(["NodeList", "DOMTokenList"]);
|
|
43
46
|
|
|
44
|
-
// WebIDL legacy platform objects with a named property getter, and whether
|
|
45
|
-
// their named properties are enumerable (DOMStringMap) and writable/deletable
|
|
46
|
-
// (DOMStringMap has a named setter/deleter; HTMLCollection/NamedNodeMap are
|
|
47
|
-
// read-only — `coll[name] = x` / `delete coll[name]` reject in strict mode).
|
|
48
|
-
const NAMED_PROP_COLLECTIONS = new Map([
|
|
49
|
-
["HTMLCollection", { enumerable: false, writable: false }],
|
|
50
|
-
["HTMLFormControlsCollection", { enumerable: false, writable: false }],
|
|
51
|
-
// HTMLFormElement is [LegacyOverrideBuiltIns]: a named control shadows the
|
|
52
|
-
// form's own prototype members (`form.submit`, `form.action`, `form.length`
|
|
53
|
-
// return the matching control), so its named props resolve BEFORE the chain.
|
|
54
|
-
["HTMLFormElement", { enumerable: false, writable: false, overrideBuiltins: true }],
|
|
55
|
-
["HTMLOptionsCollection", { enumerable: false, writable: false }],
|
|
56
|
-
["NamedNodeMap", { enumerable: false, writable: false }],
|
|
57
|
-
// [LegacyOverrideBuiltIns]: a data-* name resolves BEFORE anything on
|
|
58
|
-
// DOMStringMap.prototype, so `dataset.constructor` is the stored value when
|
|
59
|
-
// there is one.
|
|
60
|
-
["DOMStringMap", { enumerable: true, writable: true, overrideBuiltins: true }],
|
|
61
|
-
// Storage (localStorage/sessionStorage): named getter/setter/deleter, keys
|
|
62
|
-
// enumerable; the named setter takes a DOMString value (ToString-coerced
|
|
63
|
-
// JS-side below, like DOMStringMap).
|
|
64
|
-
["Storage", { enumerable: true, writable: true }],
|
|
65
|
-
]);
|
|
66
|
-
|
|
67
|
-
// [LegacyNullToEmptyString] DOMString setters: null becomes "", any other
|
|
68
|
-
// value is ToString-coerced JS-side before crossing into Ruby.
|
|
69
|
-
const NULL_TO_EMPTY_STRING_SETTERS = new Set([
|
|
70
|
-
"innerHTML", "outerHTML", "border", "color", "mediaText", "innerText", "outerText"
|
|
71
|
-
]);
|
|
72
|
-
// The same, for the names that are [LegacyNullToEmptyString] on one interface
|
|
73
|
-
// and a plain DOMString on another: `data` is on CharacterData but not on an
|
|
74
|
-
// ObjectElement or a MessageEvent, and `value` is on the two text controls
|
|
75
|
-
// but on none of the ten other interfaces that have one.
|
|
76
|
-
const INTERFACE_NULL_TO_EMPTY_STRING_SETTERS = {
|
|
77
|
-
CharacterData: ["data"],
|
|
78
|
-
HTMLInputElement: ["value"],
|
|
79
|
-
HTMLTextAreaElement: ["value"]
|
|
80
|
-
};
|
|
81
|
-
|
|
82
47
|
// Form-control value-like properties exposed as accessor descriptors on the
|
|
83
48
|
// interface prototype (see protoForChain) — what React's value-tracker reads
|
|
84
49
|
// and wraps to detect user input on controlled components.
|
|
@@ -105,6 +70,11 @@ globalThis.__rbIdl = (function () {
|
|
|
105
70
|
// The legend's form back-ref is readonly (HTML's form-associated interfaces
|
|
106
71
|
// all expose one this way); assert_readonly walks the prototype for it.
|
|
107
72
|
HTMLLegendElement: ["form"],
|
|
73
|
+
// DOMException's attributes are all readonly. On the prototype, a record
|
|
74
|
+
// conversion of DOMException.prototype finds them enumerable and reads
|
|
75
|
+
// them, and the getter's brand check throws, as WebIDL has it
|
|
76
|
+
// (url/urlsearchparams-constructor.any.js).
|
|
77
|
+
DOMException: ["name", "message", "code"],
|
|
108
78
|
};
|
|
109
79
|
|
|
110
80
|
// [LegacyUnforgeable] attributes are own accessor properties on EACH instance
|
|
@@ -210,7 +180,7 @@ globalThis.__rbIdl = (function () {
|
|
|
210
180
|
// (`rule.type === CSSRule.STYLE_RULE`).
|
|
211
181
|
const CSSRULE_CONSTANTS = {
|
|
212
182
|
STYLE_RULE: 1, CHARSET_RULE: 2, IMPORT_RULE: 3, MEDIA_RULE: 4, FONT_FACE_RULE: 5,
|
|
213
|
-
PAGE_RULE: 6, MARGIN_RULE: 9, NAMESPACE_RULE: 10
|
|
183
|
+
PAGE_RULE: 6, KEYFRAMES_RULE: 7, KEYFRAME_RULE: 8, MARGIN_RULE: 9, NAMESPACE_RULE: 10
|
|
214
184
|
};
|
|
215
185
|
|
|
216
186
|
// EventSource / FileReader ready-state [Constant]s.
|
|
@@ -223,6 +193,9 @@ globalThis.__rbIdl = (function () {
|
|
|
223
193
|
DOM_KEY_LOCATION_RIGHT: 0x02, DOM_KEY_LOCATION_NUMPAD: 0x03
|
|
224
194
|
};
|
|
225
195
|
|
|
196
|
+
// WheelEvent.deltaMode [Constant]s.
|
|
197
|
+
const WHEELEVENT_CONSTANTS = { DOM_DELTA_PIXEL: 0x00, DOM_DELTA_LINE: 0x01, DOM_DELTA_PAGE: 0x02 };
|
|
198
|
+
|
|
226
199
|
// HTMLMediaElement networkState / readyState, and HTMLTrackElement readyState.
|
|
227
200
|
const HTMLMEDIAELEMENT_CONSTANTS = {
|
|
228
201
|
NETWORK_EMPTY: 0, NETWORK_IDLE: 1, NETWORK_LOADING: 2, NETWORK_NO_SOURCE: 3,
|
|
@@ -240,7 +213,7 @@ globalThis.__rbIdl = (function () {
|
|
|
240
213
|
WebSocket: WEBSOCKET_CONSTANTS, Range: RANGE_CONSTANTS, XMLHttpRequest: XHR_CONSTANTS,
|
|
241
214
|
DOMException: DOMEXCEPTION_CONSTANTS, CSSRule: CSSRULE_CONSTANTS,
|
|
242
215
|
EventSource: EVENTSOURCE_CONSTANTS, FileReader: FILEREADER_CONSTANTS,
|
|
243
|
-
KeyboardEvent: KEYBOARDEVENT_CONSTANTS,
|
|
216
|
+
KeyboardEvent: KEYBOARDEVENT_CONSTANTS, WheelEvent: WHEELEVENT_CONSTANTS,
|
|
244
217
|
HTMLMediaElement: HTMLMEDIAELEMENT_CONSTANTS,
|
|
245
218
|
HTMLTrackElement: HTMLTRACKELEMENT_CONSTANTS
|
|
246
219
|
};
|
|
@@ -370,6 +343,18 @@ globalThis.__rbIdl = (function () {
|
|
|
370
343
|
m: ["click", "focus", "blur"],
|
|
371
344
|
p: ["title", "lang", "dir", "hidden", "innerText"]
|
|
372
345
|
},
|
|
346
|
+
// The URL Standard's interfaces. URL's two readonly attributes are in
|
|
347
|
+
// READONLY_ATTRS; URLSearchParams' iterable<> methods (entries, keys,
|
|
348
|
+
// values, forEach, @@iterator) are installed with the other pair
|
|
349
|
+
// iterables (ENTRIES_ITERABLES).
|
|
350
|
+
URL: {
|
|
351
|
+
m: ["toJSON", "toString"],
|
|
352
|
+
p: ["href", "protocol", "username", "password", "host", "hostname", "port", "pathname", "search", "hash"]
|
|
353
|
+
},
|
|
354
|
+
URLSearchParams: {
|
|
355
|
+
m: ["append", "delete", "get", "getAll", "has", "set", "sort", "toString"],
|
|
356
|
+
g: ["size"]
|
|
357
|
+
},
|
|
373
358
|
// Event interfaces: seed the readonly attributes so they exist on the
|
|
374
359
|
// prototype (WebIDL) — `("view" in ev)` / hasOwnProperty / getOwnPropertyDescriptor
|
|
375
360
|
// resolve, and `Object.getPrototypeOf` walks the right chain. The get trap
|
|
@@ -395,7 +380,11 @@ globalThis.__rbIdl = (function () {
|
|
|
395
380
|
HTMLCollection: { m: ["item", "namedItem"] },
|
|
396
381
|
NodeList: { m: ["item"] },
|
|
397
382
|
StyleSheetList: { m: ["item"] },
|
|
398
|
-
NamedNodeMap: { m: ["item", "getNamedItem", "getNamedItemNS"] }
|
|
383
|
+
NamedNodeMap: { m: ["item", "getNamedItem", "getNamedItemNS"] },
|
|
384
|
+
// Storage touches no DOM, so its mutating operations resolve to the
|
|
385
|
+
// prototype too: `storage.setItem === Storage.prototype.setItem`, and a
|
|
386
|
+
// stored "setItem" key does not shadow the method.
|
|
387
|
+
Storage: { m: ["key", "getItem", "setItem", "removeItem", "clear"] }
|
|
399
388
|
};
|
|
400
389
|
// WebIDL `[Unscopable]` members: each interface prototype that declares them
|
|
401
390
|
// exposes a `@@unscopables` object so `with (element) { remove }` resolves to
|
|
@@ -414,9 +403,13 @@ globalThis.__rbIdl = (function () {
|
|
|
414
403
|
// ChildNode only.
|
|
415
404
|
DocumentType: ["after", "before", "remove", "replaceWith"]
|
|
416
405
|
};
|
|
417
|
-
//
|
|
418
|
-
//
|
|
419
|
-
|
|
406
|
+
// Collection operations that resolve to their prototype function (identity +
|
|
407
|
+
// arity) rather than a per-instance get-trap closure: the read-only ones, and
|
|
408
|
+
// Storage's.
|
|
409
|
+
const PROTO_RESOLVED_METHODS = new Set([
|
|
410
|
+
"item", "namedItem", "getNamedItem", "getNamedItemNS",
|
|
411
|
+
"key", "getItem", "setItem", "removeItem", "clear",
|
|
412
|
+
]);
|
|
420
413
|
// WebIDL `(Node or DOMString)...` variadic operations: each argument is a
|
|
421
414
|
// Node if it's one of our host proxies, otherwise it's ToString-coerced
|
|
422
415
|
// (so `before(null)` inserts the text "null", `before(undefined)` -> "undefined",
|
|
@@ -426,48 +419,6 @@ globalThis.__rbIdl = (function () {
|
|
|
426
419
|
"before", "after", "replaceWith", "prepend", "append", "replaceChildren"
|
|
427
420
|
]);
|
|
428
421
|
|
|
429
|
-
// The event handler CONTENT attributes HTML (with Pointer/Touch/Animation
|
|
430
|
-
// Events) defines on elements. An `on*` attribute outside this set is not a
|
|
431
|
-
// handler and must stay inert: `onreadystatechange` and `onvisibilitychange`
|
|
432
|
-
// are IDL attributes of Document only, and `div.setAttribute("onfoobar", …)`
|
|
433
|
-
// names no event handler at all.
|
|
434
|
-
const ELEMENT_HANDLER_ATTRIBUTES = new Set([
|
|
435
|
-
"onabort", "onauxclick", "onbeforeinput", "onbeforetoggle", "onblur", "oncancel",
|
|
436
|
-
"oncanplay", "oncanplaythrough", "onchange", "onclick", "onclose", "oncommand",
|
|
437
|
-
"oncontextlost", "oncontextmenu", "oncontextrestored", "oncopy", "oncuechange",
|
|
438
|
-
"oncut", "ondblclick", "ondrag", "ondragend", "ondragenter", "ondragleave",
|
|
439
|
-
"ondragover", "ondragstart", "ondrop", "ondurationchange", "onemptied", "onended",
|
|
440
|
-
"onerror", "onfocus", "onfocusin", "onfocusout", "onformdata", "oninput",
|
|
441
|
-
"oninvalid", "onkeydown", "onkeypress", "onkeyup", "onload", "onloadeddata",
|
|
442
|
-
"onloadedmetadata", "onloadstart", "onmousedown", "onmouseenter", "onmouseleave",
|
|
443
|
-
"onmousemove", "onmouseout", "onmouseover", "onmouseup", "onpaste", "onpause",
|
|
444
|
-
"onplay", "onplaying", "onprogress", "onratechange", "onreset", "onresize",
|
|
445
|
-
"onscroll", "onscrollend", "onsecuritypolicyviolation", "onseeked", "onseeking",
|
|
446
|
-
"onselect", "onselectstart", "onslotchange", "onstalled", "onsubmit", "onsuspend",
|
|
447
|
-
"ontimeupdate", "ontoggle", "onvolumechange", "onwaiting", "onwheel",
|
|
448
|
-
"onanimationstart", "onanimationend", "onanimationiteration",
|
|
449
|
-
"ongotpointercapture", "onlostpointercapture", "onpointercancel", "onpointerdown",
|
|
450
|
-
"onpointerenter", "onpointerleave", "onpointermove", "onpointerout",
|
|
451
|
-
"onpointerover", "onpointerrawupdate", "onpointerup",
|
|
452
|
-
"ontouchcancel", "ontouchend", "ontouchmove", "ontouchstart",
|
|
453
|
-
]);
|
|
454
|
-
|
|
455
|
-
// Window event handlers that `body` and `frameset` — and only those two —
|
|
456
|
-
// additionally carry as content attributes, reflecting onto the Window.
|
|
457
|
-
const WINDOW_REFLECTED_HANDLERS = new Set([
|
|
458
|
-
"onafterprint", "onbeforeprint", "onbeforeunload", "onhashchange",
|
|
459
|
-
"onlanguagechange", "onmessage", "onmessageerror", "onoffline", "ononline",
|
|
460
|
-
"onpagehide", "onpageshow", "onpopstate", "onrejectionhandled", "onstorage",
|
|
461
|
-
"onunhandledrejection", "onunload",
|
|
462
|
-
]);
|
|
463
|
-
|
|
464
|
-
// On body/frameset, blur/error/focus/load/resize/scroll are the Window's
|
|
465
|
-
// handlers too, so they reflect there like the rest of WINDOW_REFLECTED.
|
|
466
|
-
const BODY_REFLECTED_HANDLERS = new Set([
|
|
467
|
-
...WINDOW_REFLECTED_HANDLERS,
|
|
468
|
-
"onblur", "onerror", "onfocus", "onload", "onresize", "onscroll",
|
|
469
|
-
]);
|
|
470
|
-
|
|
471
422
|
// WebIDL operation `length` = the count of required arguments (it stops at the
|
|
472
423
|
// first optional or variadic one). Our stubs use rest params, so they report 0;
|
|
473
424
|
// stamp the spec length where a WPT test — or a `.length`-branching helper like
|
|
@@ -527,11 +478,11 @@ globalThis.__rbIdl = (function () {
|
|
|
527
478
|
// default 0 and is absent here (Blob, FormData, Document, CustomElementRegistry,
|
|
528
479
|
// the HTML element interfaces, …).
|
|
529
480
|
const CONSTRUCTOR_ARITY = {
|
|
530
|
-
BroadcastChannel: 1, ByteLengthQueuingStrategy: 1, CompositionEvent: 1,
|
|
481
|
+
BroadcastChannel: 1, ByteLengthQueuingStrategy: 1, CommandEvent: 1, CompositionEvent: 1,
|
|
531
482
|
CountQueuingStrategy: 1, CustomEvent: 1, DeviceMotionEvent: 1,
|
|
532
483
|
DeviceOrientationEvent: 1, DragEvent: 1, ErrorEvent: 1, Event: 1,
|
|
533
484
|
EventSource: 1, File: 2, FocusEvent: 1, FormDataEvent: 2, HashChangeEvent: 1, InputEvent: 1,
|
|
534
|
-
KeyboardEvent: 1, MessageEvent: 1, MutationObserver: 1, PopStateEvent: 1,
|
|
485
|
+
KeyboardEvent: 1, MessageEvent: 1, MutationObserver: 1, PageTransitionEvent: 1, PopStateEvent: 1,
|
|
535
486
|
ProcessingInstruction: 1, ProgressEvent: 1, PromiseRejectionEvent: 2,
|
|
536
487
|
Request: 1, StaticRange: 1, StorageEvent: 1, SubmitEvent: 1,
|
|
537
488
|
ToggleEvent: 1, UIEvent: 1, URL: 1, Worker: 1
|
|
@@ -551,7 +502,7 @@ globalThis.__rbIdl = (function () {
|
|
|
551
502
|
"preventDefault", "stopPropagation", "stopImmediatePropagation", "initEvent", "initCustomEvent",
|
|
552
503
|
"initStorageEvent", "initTextEvent", "initDeviceMotionEvent", "initDeviceOrientationEvent",
|
|
553
504
|
"focus", "blur", "click", "select", "setCustomValidity", "stepUp", "stepDown", "setSelectionRange",
|
|
554
|
-
"setRangeText", "setPointerCapture",
|
|
505
|
+
"setRangeText", "showPicker", "setPointerCapture",
|
|
555
506
|
"releasePointerCapture", "observe", "unobserve", "disconnect", "setStart", "setEnd", "setStartBefore",
|
|
556
507
|
"setStartAfter", "setEndBefore", "setEndAfter", "selectNode", "selectNodeContents", "deleteContents",
|
|
557
508
|
"insertNode", "surroundContents", "detach", "removeAllRanges", "addRange", "removeRange", "collapse",
|
|
@@ -569,13 +520,14 @@ globalThis.__rbIdl = (function () {
|
|
|
569
520
|
"deleteTHead", "drawFocusIfNeeded", "drawImage", "ellipse", "empty", "fill", "fillRect", "fillText",
|
|
570
521
|
"go", "hidePopover", "initKeyboardEvent", "initMessageEvent", "initUIEvent", "insertData", "lineTo",
|
|
571
522
|
"load", "moveTo", "pause", "postMessage", "putImageData", "quadraticCurveTo", "queueMicrotask",
|
|
572
|
-
"rect", "removeListener", "removeRule", "replaceData", "replaceSync", "reportError", "
|
|
523
|
+
"rect", "removeListener", "removeRule", "replaceData", "replaceSync", "reportError", "requestClose",
|
|
524
|
+
"requestSubmit", "reset",
|
|
573
525
|
"resetTransform", "resizeTo", "restore", "rotate", "roundRect", "save", "scale", "send",
|
|
574
526
|
"set", "setData", "setLineDash", "setTransform", "show", "showModal", "showPopover",
|
|
575
527
|
"sort", "stroke", "strokeRect", "strokeText", "submit", "terminate", "throwIfAborted",
|
|
576
528
|
"toBlob", "transform", "translate", "upgrade", "writeln", "add", "getAsString",
|
|
577
529
|
"readAsArrayBuffer", "readAsBinaryString", "readAsDataURL", "readAsText", "back", "forward", "reload",
|
|
578
|
-
"start", "enqueue", "error", "releaseLock",
|
|
530
|
+
"start", "enqueue", "error", "releaseLock", "setFormValue", "setValidity", "setHTMLUnsafe",
|
|
579
531
|
]);
|
|
580
532
|
|
|
581
533
|
// Operations whose return type depends on the interface, so a table keyed by
|
|
@@ -593,6 +545,7 @@ globalThis.__rbIdl = (function () {
|
|
|
593
545
|
Document: ["close", "write", "writeln"],
|
|
594
546
|
EventSource: ["close"],
|
|
595
547
|
HTMLDialogElement: ["close"],
|
|
548
|
+
HTMLMarqueeElement: ["stop"],
|
|
596
549
|
MessagePort: ["close"],
|
|
597
550
|
ReadableStreamDefaultController: ["close"],
|
|
598
551
|
AbortController: ["abort"],
|
|
@@ -615,9 +568,6 @@ globalThis.__rbIdl = (function () {
|
|
|
615
568
|
INDEXED_SETTER_INTERFACES,
|
|
616
569
|
ENTRIES_ITERABLES,
|
|
617
570
|
PAIR_ITERABLE_COLLECTIONS,
|
|
618
|
-
NAMED_PROP_COLLECTIONS,
|
|
619
|
-
NULL_TO_EMPTY_STRING_SETTERS,
|
|
620
|
-
INTERFACE_NULL_TO_EMPTY_STRING_SETTERS,
|
|
621
571
|
FORM_VALUE_FIELDS,
|
|
622
572
|
READONLY_ATTRS,
|
|
623
573
|
UNFORGEABLE_ATTRS,
|
|
@@ -630,9 +580,6 @@ globalThis.__rbIdl = (function () {
|
|
|
630
580
|
INTERFACE_UNSCOPABLES,
|
|
631
581
|
PROTO_RESOLVED_METHODS,
|
|
632
582
|
NODE_OR_STRING_METHODS,
|
|
633
|
-
ELEMENT_HANDLER_ATTRIBUTES,
|
|
634
|
-
WINDOW_REFLECTED_HANDLERS,
|
|
635
|
-
BODY_REFLECTED_HANDLERS,
|
|
636
583
|
METHOD_ARITY,
|
|
637
584
|
INTERFACE_METHOD_ARITY,
|
|
638
585
|
CONSTRUCTOR_ARITY,
|
|
@@ -17,8 +17,11 @@ module Dommy
|
|
|
17
17
|
# HostBridge#window= used to spell all of it out, which left a setter
|
|
18
18
|
# carrying eight side effects and no name for the thing they add up to.
|
|
19
19
|
class WindowWiring
|
|
20
|
-
def initialize(backend, constructor_resolver:, custom_elements:,
|
|
20
|
+
def initialize(backend, script_runner:, event_handler_compiler:, constructor_resolver:, custom_elements:,
|
|
21
|
+
microtask_scheduler:)
|
|
21
22
|
@backend = backend
|
|
23
|
+
@script_runner = script_runner
|
|
24
|
+
@event_handler_compiler = event_handler_compiler
|
|
22
25
|
@constructor_resolver = constructor_resolver
|
|
23
26
|
@custom_elements = custom_elements
|
|
24
27
|
@microtask_scheduler = microtask_scheduler
|
|
@@ -56,13 +59,14 @@ module Dommy
|
|
|
56
59
|
window.scheduler.native_microtask_scheduler = @microtask_scheduler
|
|
57
60
|
end
|
|
58
61
|
|
|
59
|
-
# Let a classic <script> inserted into the document execute
|
|
60
|
-
#
|
|
62
|
+
# Let a classic <script> inserted into the document execute, and an event
|
|
63
|
+
# handler content attribute compile (Dommy has no JS engine; it calls
|
|
64
|
+
# back here to run the body in global scope or build the function).
|
|
61
65
|
def wire_script_runner!(window)
|
|
62
66
|
return unless window.respond_to?(:document) && window.document.respond_to?(:script_runner=)
|
|
63
67
|
|
|
64
|
-
|
|
65
|
-
window.document.
|
|
68
|
+
window.document.script_runner = @script_runner
|
|
69
|
+
window.document.event_handler_compiler = @event_handler_compiler
|
|
66
70
|
end
|
|
67
71
|
end
|
|
68
72
|
end
|
data/lib/dommy/location.rb
CHANGED
|
@@ -63,18 +63,18 @@ module Dommy
|
|
|
63
63
|
__internal_navigate_to__(value.to_s, replace: false, source: :location)
|
|
64
64
|
when "hash"
|
|
65
65
|
set_hash(value.to_s)
|
|
66
|
-
when "pathname"
|
|
67
|
-
self.pathname = value.to_s
|
|
68
66
|
when "search"
|
|
69
67
|
set_search(value.to_s)
|
|
68
|
+
when "pathname"
|
|
69
|
+
navigate_copy { |copy| copy.pathname = value.to_s }
|
|
70
70
|
when "host"
|
|
71
|
-
|
|
71
|
+
navigate_copy { |copy| copy.host = value.to_s }
|
|
72
72
|
when "hostname"
|
|
73
|
-
|
|
73
|
+
navigate_copy { |copy| copy.hostname = value.to_s }
|
|
74
74
|
when "port"
|
|
75
|
-
|
|
75
|
+
navigate_copy { |copy| copy.port = value.to_s }
|
|
76
76
|
when "protocol"
|
|
77
|
-
|
|
77
|
+
set_protocol(value.to_s)
|
|
78
78
|
end
|
|
79
79
|
end
|
|
80
80
|
|
|
@@ -99,23 +99,22 @@ module Dommy
|
|
|
99
99
|
Internal::UrlParser.serialize(@record)
|
|
100
100
|
end
|
|
101
101
|
|
|
102
|
-
# Internal — accepts an absolute or relative
|
|
103
|
-
#
|
|
104
|
-
#
|
|
105
|
-
#
|
|
106
|
-
#
|
|
107
|
-
#
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
102
|
+
# Internal — establish the document's URL: accepts an absolute or relative
|
|
103
|
+
# URL string and updates the record, without navigating and without firing
|
|
104
|
+
# any event. Called by embedders when they know where the document lives,
|
|
105
|
+
# and by History for its own URL updates. A parse failure leaves the record
|
|
106
|
+
# unchanged. (`fire_hash` is accepted for compatibility and ignored: every
|
|
107
|
+
# hashchange now comes from a fragment navigation or a traversal.)
|
|
108
|
+
def __internal_set_url__(raw, fire_hash: false) # rubocop:disable Lint/UnusedMethodArgument
|
|
109
|
+
@record = Internal::UrlParser.parse(raw, @record)
|
|
110
|
+
nil
|
|
111
111
|
rescue Internal::UrlParser::Failure
|
|
112
112
|
nil
|
|
113
113
|
end
|
|
114
114
|
|
|
115
115
|
# `location.href = X` / `assign` / `replace`, and the shared entry point for
|
|
116
|
-
# a hyperlink's follow-the-hyperlink.
|
|
117
|
-
#
|
|
118
|
-
# other change is cross-document — the intent is handed to the delegate.
|
|
116
|
+
# a hyperlink's follow-the-hyperlink. `raw` is parsed against the document
|
|
117
|
+
# base URL; then it is navigated to (see #navigate_record).
|
|
119
118
|
#
|
|
120
119
|
# `sync_cross_doc` controls whether a cross-document target also mutates the
|
|
121
120
|
# URL parts synchronously: true for `location.href=`/assign/replace (a
|
|
@@ -135,40 +134,68 @@ module Dommy
|
|
|
135
134
|
|
|
136
135
|
return
|
|
137
136
|
end
|
|
138
|
-
|
|
139
|
-
|
|
137
|
+
replace ||= source == :location && loading_without_activation?
|
|
138
|
+
navigate_record(target, source: source, replace: replace, sync_cross_doc: sync_cross_doc)
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
private
|
|
142
|
+
|
|
143
|
+
# HTML "Location-object navigate" step 2: while the document is still
|
|
144
|
+
# loading, a navigation made by script without transient user activation
|
|
145
|
+
# replaces the current entry instead of adding one. One a click handler
|
|
146
|
+
# makes during the load is the user's, and adds an entry.
|
|
147
|
+
def loading_without_activation?
|
|
148
|
+
!@window.__internal_completely_loaded__? && !@window.__internal_transient_activation__?
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
# The navigate algorithm's history handling and its same-document branch.
|
|
152
|
+
# A URL equal to the document's own is a "replace"; so is any navigation
|
|
153
|
+
# away from an initial about:blank document. A URL that differs from the
|
|
154
|
+
# active entry's only in its fragment — and HAS a fragment — is a fragment
|
|
155
|
+
# navigation, which stays in this document; anything else is
|
|
156
|
+
# cross-document and handed to the navigation delegate.
|
|
157
|
+
def navigate_record(target, source:, replace:, sync_cross_doc:)
|
|
158
|
+
url = Internal::UrlParser.serialize(target)
|
|
159
|
+
replace = true if url == href || @window.__internal_initial_about_blank__?
|
|
160
|
+
if !target.fragment.nil? && same_document?(@record, target)
|
|
161
|
+
@window.history.__internal_navigate_to_fragment__(url, replace: replace)
|
|
140
162
|
else
|
|
141
|
-
|
|
142
|
-
@window.__internal_navigate__(url:
|
|
163
|
+
@record = target if sync_cross_doc
|
|
164
|
+
@window.__internal_navigate__(url: url, method: "GET", replace: replace, source: source)
|
|
143
165
|
end
|
|
166
|
+
nil
|
|
144
167
|
end
|
|
145
168
|
|
|
146
|
-
|
|
169
|
+
# Location-object navigate to an edited copy of this Location's URL — the
|
|
170
|
+
# shared tail of the host / hostname / port / pathname setters. The block
|
|
171
|
+
# edits the copy through the URL-component setters.
|
|
172
|
+
def navigate_copy
|
|
173
|
+
copy = RecordEditor.new(copy_record)
|
|
174
|
+
yield copy
|
|
175
|
+
location_object_navigate(copy.record)
|
|
176
|
+
end
|
|
177
|
+
|
|
178
|
+
def location_object_navigate(target)
|
|
179
|
+
replace = loading_without_activation?
|
|
180
|
+
navigate_record(target, source: :location, replace: replace, sync_cross_doc: true)
|
|
181
|
+
end
|
|
182
|
+
|
|
183
|
+
def copy_record = @record.dup
|
|
147
184
|
|
|
148
|
-
# Resolve a possibly-relative URL against the
|
|
185
|
+
# Resolve a possibly-relative URL against the document base URL with the
|
|
149
186
|
# URL parser; nil when it fails. Returns a Record, not a string, so
|
|
150
|
-
# `__internal_navigate_to__` can both compare fields and
|
|
151
|
-
# `apply_record`) adopt it directly, without a second parse.
|
|
187
|
+
# `__internal_navigate_to__` can both compare fields and adopt it directly.
|
|
152
188
|
def resolve(raw)
|
|
153
|
-
|
|
189
|
+
base = @window.document&.base_uri.to_s
|
|
190
|
+
Internal::UrlParser.parse(raw, base.empty? ? @record : Internal::UrlParser.parse(base))
|
|
154
191
|
rescue Internal::UrlParser::Failure
|
|
155
192
|
nil
|
|
156
193
|
end
|
|
157
194
|
|
|
158
195
|
# Two URLs address the same document when everything but the fragment matches.
|
|
159
196
|
def same_document?(a, b)
|
|
160
|
-
a.scheme == b.scheme && a.
|
|
161
|
-
a.path == b.path && a.query == b.query
|
|
162
|
-
end
|
|
163
|
-
|
|
164
|
-
# Replace the record wholesale (a full href/assign/replace/pushState
|
|
165
|
-
# navigation, as opposed to set_hash's in-place fragment edit), firing
|
|
166
|
-
# hashchange when the visible hash actually changed.
|
|
167
|
-
def apply_record(record, fire_hash: true)
|
|
168
|
-
previous_hash = current_hash
|
|
169
|
-
previous_href = href
|
|
170
|
-
@record = record
|
|
171
|
-
@window.fire_hashchange(previous_href, href) if fire_hash && previous_hash != current_hash
|
|
197
|
+
a.scheme == b.scheme && a.username == b.username && a.password == b.password &&
|
|
198
|
+
a.host == b.host && a.port == b.port && a.path == b.path && a.query == b.query
|
|
172
199
|
end
|
|
173
200
|
|
|
174
201
|
# Whether this Location still has a browsing context to navigate. A nested
|
|
@@ -176,8 +203,7 @@ module Dommy
|
|
|
176
203
|
# Window survives (a script may still hold it), the navigable does not. A
|
|
177
204
|
# top-level Window has no frame element and always has one.
|
|
178
205
|
def browsing_context?
|
|
179
|
-
|
|
180
|
-
frame.nil? || frame.is_connected?
|
|
206
|
+
@window.navigable?
|
|
181
207
|
end
|
|
182
208
|
|
|
183
209
|
# `location.ancestorOrigins` — the origins of this browsing context's
|
|
@@ -186,11 +212,9 @@ module Dommy
|
|
|
186
212
|
#
|
|
187
213
|
# [SameObject], so the list is built once and answers live: a page that
|
|
188
214
|
# holds `location.ancestorOrigins` holds the same object the next read would
|
|
189
|
-
# give it, which is what the IDL promises
|
|
190
|
-
# DOMStringList the IDL names — indexing, `length` and `item` are there,
|
|
191
|
-
# `contains` is not, and it reports as a NodeList.
|
|
215
|
+
# give it, which is what the IDL promises: a live DOMStringList.
|
|
192
216
|
def ancestor_origins
|
|
193
|
-
@ancestor_origins ||=
|
|
217
|
+
@ancestor_origins ||= DOMStringList.new { current_ancestor_origins }
|
|
194
218
|
end
|
|
195
219
|
|
|
196
220
|
def current_ancestor_origins
|
|
@@ -210,10 +234,10 @@ module Dommy
|
|
|
210
234
|
# A Location with no browsing context has an opaque origin, which
|
|
211
235
|
# serializes as "null".
|
|
212
236
|
return "null" unless browsing_context?
|
|
213
|
-
return "" if @record.host.nil?
|
|
214
237
|
|
|
215
|
-
|
|
216
|
-
"
|
|
238
|
+
# The URL's origin: a tuple for http(s) and the other special schemes,
|
|
239
|
+
# opaque ("null") for about:blank, data:, file: and the like.
|
|
240
|
+
Internal::Origin.of_url(href)
|
|
217
241
|
end
|
|
218
242
|
|
|
219
243
|
def current_search
|
|
@@ -226,41 +250,70 @@ module Dommy
|
|
|
226
250
|
f.nil? || f.empty? ? "" : "##{f}"
|
|
227
251
|
end
|
|
228
252
|
|
|
253
|
+
# The hash setter: parse the value into a copy's (emptied) fragment; leave
|
|
254
|
+
# the URL alone when the fragment would not change (deployed content sets
|
|
255
|
+
# `location.hash` redundantly on scroll), otherwise navigate — which, the
|
|
256
|
+
# rest of the URL being equal, is a fragment navigation.
|
|
257
|
+
#
|
|
258
|
+
# This is where Location parts company with the URL API, deliberately:
|
|
259
|
+
# `url.hash = ""` sets the fragment to NULL and the "#" goes away, whereas
|
|
260
|
+
# here the copy's fragment is first set to the EMPTY STRING, so clearing a
|
|
261
|
+
# fragment that is there leaves the "#" behind ("?q=1#x" -> "?q=1#"). Both
|
|
262
|
+
# are pinned by WPT (location-hash-setter-empty-string.html and
|
|
263
|
+
# url/url-setters).
|
|
264
|
+
# https://html.spec.whatwg.org/multipage/nav-history-apis.html#dom-location-hash
|
|
229
265
|
def set_hash(value)
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
#
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
# `hash = ""` ends at "?q=1#". A URL with no fragment has nothing to
|
|
238
|
-
# clear, and the setter's final step (return unless the fragment
|
|
239
|
-
# changed) leaves it alone rather than growing a "#".
|
|
240
|
-
#
|
|
241
|
-
# This is where Location parts company with the URL API, deliberately:
|
|
242
|
-
# `url.hash = ""` sets the fragment to NULL and the "#" goes away. Both
|
|
243
|
-
# are pinned by WPT (location-hash-setter-empty-string.html and
|
|
244
|
-
# url/url-setters), so neither setter can borrow the other's rule.
|
|
245
|
-
# https://html.spec.whatwg.org/multipage/nav-history-apis.html#dom-location-hash
|
|
246
|
-
return if @record.fragment.nil?
|
|
247
|
-
|
|
248
|
-
@record.fragment = +""
|
|
249
|
-
else
|
|
250
|
-
@record.fragment = +""
|
|
251
|
-
parse_into(v, :fragment)
|
|
266
|
+
this_fragment = @record.fragment || ""
|
|
267
|
+
copy = copy_record
|
|
268
|
+
copy.fragment = +""
|
|
269
|
+
begin
|
|
270
|
+
Internal::UrlParser.parse_with_override(value.delete_prefix("#"), copy, :fragment)
|
|
271
|
+
rescue Internal::UrlParser::Failure
|
|
272
|
+
nil
|
|
252
273
|
end
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
274
|
+
return if copy.fragment == this_fragment
|
|
275
|
+
|
|
276
|
+
location_object_navigate(copy)
|
|
256
277
|
end
|
|
257
278
|
|
|
258
279
|
def set_search(value)
|
|
280
|
+
copy = copy_record
|
|
259
281
|
if value.empty?
|
|
260
|
-
|
|
282
|
+
copy.query = nil
|
|
261
283
|
else
|
|
262
|
-
|
|
263
|
-
|
|
284
|
+
copy.query = +""
|
|
285
|
+
begin
|
|
286
|
+
Internal::UrlParser.parse_with_override(value.delete_prefix("?"), copy, :query)
|
|
287
|
+
rescue Internal::UrlParser::Failure
|
|
288
|
+
nil
|
|
289
|
+
end
|
|
290
|
+
end
|
|
291
|
+
location_object_navigate(copy)
|
|
292
|
+
end
|
|
293
|
+
|
|
294
|
+
# The protocol setter: a value the URL parser rejects is a SyntaxError, and
|
|
295
|
+
# a resulting scheme other than http(s) navigates nowhere.
|
|
296
|
+
def set_protocol(value)
|
|
297
|
+
copy = copy_record
|
|
298
|
+
begin
|
|
299
|
+
Internal::UrlParser.parse_with_override("#{value}:", copy, :scheme_start)
|
|
300
|
+
rescue Internal::UrlParser::Failure
|
|
301
|
+
raise DOMException::SyntaxError, "'#{value}' is an invalid protocol"
|
|
302
|
+
end
|
|
303
|
+
return unless %w[http https].include?(copy.scheme)
|
|
304
|
+
|
|
305
|
+
location_object_navigate(copy)
|
|
306
|
+
end
|
|
307
|
+
|
|
308
|
+
# A URL record edited through the URLUtils component setters, for the
|
|
309
|
+
# Location setters that navigate to a modified copy of the current URL.
|
|
310
|
+
class RecordEditor
|
|
311
|
+
include Internal::UrlRecordAccessors
|
|
312
|
+
|
|
313
|
+
attr_reader :record
|
|
314
|
+
|
|
315
|
+
def initialize(record)
|
|
316
|
+
@record = record
|
|
264
317
|
end
|
|
265
318
|
end
|
|
266
319
|
end
|
|
@@ -17,6 +17,7 @@ module Dommy
|
|
|
17
17
|
# Spec: https://drafts.csswg.org/cssom-view/#mediaquerylist
|
|
18
18
|
class MediaQueryList
|
|
19
19
|
include EventTarget
|
|
20
|
+
include Internal::EventHandlers::IdlAttributeBridge
|
|
20
21
|
|
|
21
22
|
attr_reader :media
|
|
22
23
|
|
|
@@ -24,7 +25,6 @@ module Dommy
|
|
|
24
25
|
@window = window
|
|
25
26
|
@media = query.to_s
|
|
26
27
|
@forced = nil
|
|
27
|
-
@onchange = nil
|
|
28
28
|
@last_matches = evaluate
|
|
29
29
|
window.__internal_register_media_query_list__(self) if window.respond_to?(:__internal_register_media_query_list__)
|
|
30
30
|
end
|
|
@@ -79,24 +79,15 @@ module Dommy
|
|
|
79
79
|
@media
|
|
80
80
|
when "matches"
|
|
81
81
|
matches
|
|
82
|
-
when "onchange"
|
|
83
|
-
@onchange
|
|
84
82
|
else
|
|
85
|
-
Bridge::ABSENT
|
|
83
|
+
event_handler_idl_attribute?(key) ? event_handler_idl_get(key) : Bridge::ABSENT
|
|
86
84
|
end
|
|
87
85
|
end
|
|
88
86
|
|
|
89
87
|
def __js_set__(key, value)
|
|
90
|
-
|
|
91
|
-
when "onchange"
|
|
92
|
-
remove_event_listener("change", @onchange) if @onchange
|
|
93
|
-
@onchange = value
|
|
94
|
-
add_event_listener("change", value) if value
|
|
95
|
-
else
|
|
96
|
-
return Bridge::UNHANDLED
|
|
97
|
-
end
|
|
88
|
+
return Bridge::UNHANDLED unless event_handler_idl_attribute?(key)
|
|
98
89
|
|
|
99
|
-
|
|
90
|
+
event_handler_idl_set(key, value)
|
|
100
91
|
end
|
|
101
92
|
|
|
102
93
|
include Bridge::Methods
|