dom: attr: fix crash w/o parent

This commit is contained in:
Pierre Tachoire
2024-01-09 16:52:28 +01:00
parent c812ff300a
commit cb3abe58c2

View File

@@ -863,6 +863,11 @@ pub fn attributeGetValue(a: *Attribute) !?[]const u8 {
} }
pub fn attributeSetValue(a: *Attribute, v: []const u8) !void { pub fn attributeSetValue(a: *Attribute, v: []const u8) !void {
// if the attribute has no owner/parent, the function crashes.
if (try attributeGetOwnerElement(a) == null) {
return DOMError.NotSupported;
}
const err = attributeVtable(a).dom_attr_set_value.?(a, try strFromData(v)); const err = attributeVtable(a).dom_attr_set_value.?(a, try strFromData(v));
try DOMErr(err); try DOMErr(err);
} }