Skip to content

Commit 0c9f282

Browse files
committed
fix(safari): use cloned Range in RangeContainer
1 parent 8174ecc commit 0c9f282

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/range-container.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@ export default class RangeContainer {
1515
this.host = editableHost && editableHost.jquery
1616
? editableHost[0]
1717
: editableHost
18-
this.range = range
18+
// Safari 17 seems to modify the range instance on the fly which breaks later comparisons.
19+
// We clone the range at the time of the RangeContainer creation.
20+
// https://developer.apple.com/documentation/safari-release-notes/safari-17-release-notes#New-Features
21+
this.range = range?.cloneRange()
1922
this.isAnythingSelected = (range !== undefined)
2023
this.isCursor = (this.isAnythingSelected && range.collapsed)
2124
this.isSelection = (this.isAnythingSelected && !this.isCursor)

0 commit comments

Comments
 (0)