diff --git a/src/browser/dom/attribute.zig b/src/browser/dom/attribute.zig index ece5a2e2..604c663f 100644 --- a/src/browser/dom/attribute.zig +++ b/src/browser/dom/attribute.zig @@ -15,7 +15,6 @@ // // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . - const parser = @import("../netsurf.zig"); const Node = @import("node.zig").Node; @@ -47,7 +46,14 @@ pub const Attr = struct { } pub fn set_value(self: *parser.Attribute, v: []const u8) !?[]const u8 { - try parser.attributeSetValue(self, v); + if (try parser.attributeGetOwnerElement(self)) |el| { + // if possible, go through the element, as that triggers a + // DOMAttrModified event (which MutationObserver cares about) + const name = try parser.attributeGetName(self); + try parser.elementSetAttribute(el, name, v); + } else { + try parser.attributeSetValue(self, v); + } return v; } diff --git a/src/browser/dom/namednodemap.zig b/src/browser/dom/namednodemap.zig index ec68782d..534ba1c3 100644 --- a/src/browser/dom/namednodemap.zig +++ b/src/browser/dom/namednodemap.zig @@ -134,5 +134,7 @@ test "Browser.DOM.NamedNodeMap" { .{ "a['id'].name", "id" }, .{ "a['id'].value", "content" }, .{ "a['other']", "undefined" }, + .{ "a[0].value = 'abc123'", null }, + .{ "a[0].value", "abc123" }, }, .{}); }