Add missing validation to range setStart and setEnd

Fixes the remaining failing cases (400!) of WPT dom/ranges/Range-set.html
This commit is contained in:
Karl Seguin
2026-02-13 13:47:26 +08:00
parent 0cae6ceca3
commit d91bec08c3

View File

@@ -37,6 +37,10 @@ pub fn init(page: *Page) !*Range {
}
pub fn setStart(self: *Range, node: *Node, offset: u32) !void {
if (node._type == .document_type) {
return error.InvalidNodeType;
}
if (offset > node.getLength()) {
return error.IndexSizeError;
}
@@ -54,6 +58,10 @@ pub fn setStart(self: *Range, node: *Node, offset: u32) !void {
}
pub fn setEnd(self: *Range, node: *Node, offset: u32) !void {
if (node._type == .document_type) {
return error.InvalidNodeType;
}
// Validate offset
if (offset > node.getLength()) {
return error.IndexSizeError;