Skip to content

fix: guard placeCaretAfterNode against empty Selection#1495

Open
LiminalSpaces wants to merge 1 commit into
yairEO:masterfrom
LiminalSpaces:fix/place-caret-empty-selection-1
Open

fix: guard placeCaretAfterNode against empty Selection#1495
LiminalSpaces wants to merge 1 commit into
yairEO:masterfrom
LiminalSpaces:fix/place-caret-empty-selection-1

Conversation

@LiminalSpaces

Copy link
Copy Markdown

Problem

placeCaretAfterNode in src/parts/helpers.js calls sel.getRangeAt(0) before checking sel.rangeCount:

var sel   = window.getSelection(),
    range = sel.getRangeAt(0);   // throws IndexSizeError when rangeCount === 0

if (sel.rangeCount) { ... }      // guard runs too late

### Problem

`placeCaretAfterNode` in `src/parts/helpers.js` calls `sel.getRangeAt(0)` before checking `sel.rangeCount`:

```js
var sel   = window.getSelection(),
    range = sel.getRangeAt(0);   // throws IndexSizeError when rangeCount === 0

if (sel.rangeCount) { ... }      // guard runs too late
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant