mirror of
https://github.com/lightpanda-io/browser.git
synced 2026-03-22 20:54:43 +00:00
Add missing validation to Range.comparePoint
Also re-order the validation to match what WPT expects. Fixes all cases in dom/ranges/Range-comparePoint.html
This commit is contained in:
@@ -186,10 +186,6 @@ pub fn compareBoundaryPoints(self: *const Range, how_raw: i32, source_range: *co
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn comparePoint(self: *const Range, node: *Node, offset: u32) !i16 {
|
pub fn comparePoint(self: *const Range, node: *Node, offset: u32) !i16 {
|
||||||
if (offset > node.getLength()) {
|
|
||||||
return error.IndexSizeError;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check if node is in a different tree than the range
|
// Check if node is in a different tree than the range
|
||||||
const node_root = node.getRootNode(null);
|
const node_root = node.getRootNode(null);
|
||||||
const start_root = self._proto._start_container.getRootNode(null);
|
const start_root = self._proto._start_container.getRootNode(null);
|
||||||
@@ -197,6 +193,14 @@ pub fn comparePoint(self: *const Range, node: *Node, offset: u32) !i16 {
|
|||||||
return error.WrongDocument;
|
return error.WrongDocument;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (node._type == .document_type) {
|
||||||
|
return error.InvalidNodeType;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (offset > node.getLength()) {
|
||||||
|
return error.IndexSizeError;
|
||||||
|
}
|
||||||
|
|
||||||
// Compare point with start boundary
|
// Compare point with start boundary
|
||||||
const cmp_start = AbstractRange.compareBoundaryPoints(
|
const cmp_start = AbstractRange.compareBoundaryPoints(
|
||||||
node,
|
node,
|
||||||
|
|||||||
Reference in New Issue
Block a user