Skip to content

Commit

Permalink
fix(safari): use cloned Range in RangeContainer
Browse files Browse the repository at this point in the history
  • Loading branch information
dfreier committed Jan 31, 2024
1 parent 8174ecc commit 0c9f282
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/range-container.js
Expand Up @@ -15,7 +15,10 @@ export default class RangeContainer {
this.host = editableHost && editableHost.jquery
? editableHost[0]
: editableHost
this.range = range
// Safari 17 seems to modify the range instance on the fly which breaks later comparisons.
// We clone the range at the time of the RangeContainer creation.
// https://developer.apple.com/documentation/safari-release-notes/safari-17-release-notes#New-Features
this.range = range?.cloneRange()
this.isAnythingSelected = (range !== undefined)
this.isCursor = (this.isAnythingSelected && range.collapsed)
this.isSelection = (this.isAnythingSelected && !this.isCursor)
Expand Down

0 comments on commit 0c9f282

Please sign in to comment.