use StaticStringMap for lookup

This commit is contained in:
Karl Seguin committed 2026-07-15 11:32:39 +08:00
1 parent 46e9497d35
commit 09a4092634
4 files changed
+10 -12

No files matched your search

+2 -5
View File
@@ -3151,11 +3151,8 @@ const SubmitFormOpts = struct {
pub fn submitForm(self: *Frame, submitter_: ?*Element, form_: ?*Element.Html.Form, submit_opts: SubmitFormOpts) !void {
const form = form_ orelse return;
// Interactive submission (submit button, requestSubmit) of a
// disconnected form does nothing; the programmatic form.submit() is
// exempt from the connectedness requirement (HTML "cannot navigate"
// only applies its connected clause to non-form elements).
if (submit_opts.fire_event and !form.asElement().asNode().isConnected()) {
if (submit_opts.fire_event and form.asNode().isConnected() == false) {
// interactive submission (e.g. submit button) noop if the form is disconnected
return;
}
+1 -1
View File
@@ -221,7 +221,7 @@ fn hasClickActivationBehavior(node: *Node) bool {
fn isEditingHost(node: *Node) bool {
const element = node.is(Element) orelse return false;
const value = element.getAttributeSafe(.wrap("contenteditable")) orelse return false;
return !std.ascii.eqlIgnoreCase(value, "false");
return std.ascii.eqlIgnoreCase(value, "false") == false;
}
// A mousedown on editable content focuses its editing host: the outermost
+7 -5
View File
@@ -107,11 +107,13 @@ const AddEventListenerOptions = union(enum) {
// event types are passive by default on the window, the document, and the
// html and body elements.
fn defaultPassiveValue(self: *EventTarget, typ: []const u8) bool {
const scroll_blocking = std.mem.eql(u8, typ, "touchstart") or
std.mem.eql(u8, typ, "touchmove") or
std.mem.eql(u8, typ, "wheel") or
std.mem.eql(u8, typ, "mousewheel");
if (!scroll_blocking) {
const scroll_blocking_event_types = std.StaticStringMap(void).initComptime(.{
.{"touchstart", {}},
.{"touchmove", {}},
.{"wheel", {}},
.{"mousewheel", {}},
});
if (scroll_blocking_event_types.has(typ) == false) {
return false;
}
-1
View File
@@ -56,7 +56,6 @@ pub fn getComputedLabel(_: *const WebDriver, element: *Element, frame: *Frame) !
// synchronously so the events are observable when the testdriver promise
// resolves.
pub fn click(_: *const WebDriver, element: *Element, frame: *Frame) !void {
// Disabled form controls don't receive real click events at all.
if (element.is(Element.Html)) |html| {
switch (html._type) {
inline .button, .input, .textarea, .select => |i| {