Skip to content

Commit

Permalink
Merge pull request #3491 from quilljs/zh-fix-4294967295
Browse files Browse the repository at this point in the history
Fix getBounds of empty text nodes
  • Loading branch information
jhchen authored Nov 29, 2021
2 parents 7406491 + baecf47 commit 7b3263b
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions core/selection.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,14 @@ class Selection {
let side = 'left';
let rect;
if (node instanceof Text) {
// Return null if the text node is empty because it is
// not able to get a useful client rect:
// https://github.com/w3c/csswg-drafts/issues/2514.
// Empty text nodes are most likely caused by TextBlot#optimize()
// not getting called when editor content changes.
if (!node.data.length) {
return null;
}
if (offset < node.data.length) {
range.setStart(node, offset);
range.setEnd(node, offset + 1);
Expand Down

0 comments on commit 7b3263b

Please sign in to comment.