mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-10-28 14:43:28 +00:00
Updates libdom
libdom's parsing is now less strict with respect to attribute names. See: https://github.com/lightpanda-io/libdom/pull/33 However, the attribute name in setAttribute has stricter validation applied to it, which we now handle directly.
This commit is contained in:
@@ -633,6 +633,7 @@ test "Browser.DOM.Element" {
|
||||
.{ "a.hasAttribute('foo')", "true" },
|
||||
.{ "a.getAttribute('foo')", "bar" },
|
||||
.{ "a.getAttributeNames()", "id,foo" },
|
||||
.{ " try { a.setAttribute('.foo', 'invalid') } catch (e) { e }", "Error: InvalidCharacterError" },
|
||||
|
||||
.{ "a.setAttribute('foo', 'baz')", "undefined" },
|
||||
.{ "a.hasAttribute('foo')", "true" },
|
||||
@@ -832,4 +833,11 @@ test "Browser.DOM.Element" {
|
||||
.{ "rm.remove()", "undefined" },
|
||||
.{ "document.getElementById('to-remove') != null", "false" },
|
||||
}, .{});
|
||||
|
||||
try runner.testCases(&.{
|
||||
.{ "const div2 = document.createElement('div');", null },
|
||||
.{ "div2.innerHTML = '<p id=1 .lit$id=9>a</p>';", null },
|
||||
.{ "div2.innerHTML", "<p id=\"1\" .lit$id=\"9\">a</p>" },
|
||||
.{ "div2.childNodes[0].getAttributeNames()", "id,.lit$id" },
|
||||
}, .{});
|
||||
}
|
||||
|
||||
@@ -1633,9 +1633,14 @@ pub fn elementGetAttributeNS(elem: *Element, ns: []const u8, name: []const u8) !
|
||||
}
|
||||
|
||||
pub fn elementSetAttribute(elem: *Element, qname: []const u8, value: []const u8) !void {
|
||||
const dom_str = try strFromData(qname);
|
||||
if (!c._dom_validate_name(dom_str)) {
|
||||
return error.InvalidCharacterError;
|
||||
}
|
||||
|
||||
const err = elementVtable(elem).dom_element_set_attribute.?(
|
||||
elem,
|
||||
try strFromData(qname),
|
||||
dom_str,
|
||||
try strFromData(value),
|
||||
);
|
||||
try DOMErr(err);
|
||||
@@ -1647,10 +1652,15 @@ pub fn elementSetAttributeNS(
|
||||
qname: []const u8,
|
||||
value: []const u8,
|
||||
) !void {
|
||||
const dom_str = try strFromData(qname);
|
||||
if (!c._dom_validate_name(dom_str)) {
|
||||
return error.InvalidCharacterError;
|
||||
}
|
||||
|
||||
const err = elementVtable(elem).dom_element_set_attribute_ns.?(
|
||||
elem,
|
||||
try strFromData(ns),
|
||||
try strFromData(qname),
|
||||
dom_str,
|
||||
try strFromData(value),
|
||||
);
|
||||
try DOMErr(err);
|
||||
|
||||
2
vendor/netsurf/libdom
vendored
2
vendor/netsurf/libdom
vendored
Submodule vendor/netsurf/libdom updated: 16a0d91684...0c590b265a
Reference in New Issue
Block a user