Skip to content

Commit

Permalink
Add getClientRects and getBoundingClientRect stubs to Range
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffrifwald committed Apr 20, 2023
1 parent f76d3a2 commit 0066ec8
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
26 changes: 26 additions & 0 deletions lib/jsdom/living/range/Range-impl.js
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,32 @@ class RangeImpl extends AbstractRangeImpl {
return parseFragment(fragment, element);
}

getBoundingClientRect() {
return {
bottom: 0,
height: 0,
left: 0,
right: 0,
top: 0,
width: 0,
x: 0,
y: 0,
};
}

getClientRects() {
return [{
bottom: 0,
height: 0,
left: 0,
right: 0,
top: 0,
width: 0,
x: 0,
y: 0,
}];
}

// https://dom.spec.whatwg.org/#concept-range-root
get _root() {
return nodeRoot(this._start.node);
Expand Down
2 changes: 2 additions & 0 deletions lib/jsdom/living/range/Range.webidl
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ interface Range : AbstractRange {
[CEReactions] undefined insertNode(Node node);
[CEReactions] undefined surroundContents(Node newParent);

[NewObject] sequence<DOMRect> getClientRects();
[NewObject] DOMRect getBoundingClientRect();
[NewObject] Range cloneRange();
undefined detach();

Expand Down

0 comments on commit 0066ec8

Please sign in to comment.