diff options
Diffstat (limited to 'polygerrit-ui/app/elements/diff/gr-diff-highlight/gr-diff-highlight.js')
-rw-r--r-- | polygerrit-ui/app/elements/diff/gr-diff-highlight/gr-diff-highlight.js | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/polygerrit-ui/app/elements/diff/gr-diff-highlight/gr-diff-highlight.js b/polygerrit-ui/app/elements/diff/gr-diff-highlight/gr-diff-highlight.js index d655002d48..00da805dba 100644 --- a/polygerrit-ui/app/elements/diff/gr-diff-highlight/gr-diff-highlight.js +++ b/polygerrit-ui/app/elements/diff/gr-diff-highlight/gr-diff-highlight.js @@ -217,6 +217,11 @@ class GrDiffHighlight extends GestureEventListeners( * })|null|!Object} */ _getNormalizedRange(selection) { + /* On Safari the ShadowRoot.getSelection() isn't there and the only thing + we can get is a single Range */ + if (selection instanceof Range) { + return this._normalizeRange(selection); + } const rangeCount = selection.rangeCount; if (rangeCount === 0) { return null; @@ -377,12 +382,21 @@ class GrDiffHighlight extends GestureEventListeners( } _handleSelection(selection, isMouseUp) { + /* On Safari, the selection events may return a null range that should + be ignored */ + if (!selection) { + return; + } const normalizedRange = this._getNormalizedRange(selection); if (!this._isRangeValid(normalizedRange)) { this._removeActionBox(); return; } - const domRange = selection.getRangeAt(0); + /* On Safari the ShadowRoot.getSelection() isn't there and the only thing + we can get is a single Range */ + const domRange = selection instanceof Range ? + selection : + selection.getRangeAt(0); const start = normalizedRange.start; const end = normalizedRange.end; |