-
Notifications
You must be signed in to change notification settings - Fork 50.3k
Minimally support iframes (nested browsing contexts) in selection event handling #12037
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
6940e33
3f3c1d7
b08a270
51be426
3714067
66b8766
75bc65e
5a61b66
f752792
a8fcf05
0003681
fef8519
799ee39
6e3d4b7
d1ad016
3c32963
3f7b5c5
05d8969
a776570
26e9d82
4db5c44
ccf0329
2edf1f8
db02b65
75b9992
0f1de45
95b2aef
d997ba8
e63391c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,10 +14,8 @@ import {TEXT_NODE} from '../shared/HTMLNodeType'; | |
| * @return {?object} | ||
| */ | ||
| export function getOffsets(outerNode) { | ||
| let win = window; | ||
| if (outerNode.ownerDocument && outerNode.ownerDocument.defaultView) { | ||
| win = outerNode.ownerDocument.defaultView; | ||
| } | ||
| const win = | ||
| (outerNode.ownerDocument && outerNode.ownerDocument.defaultView) || window; | ||
| const selection = win.getSelection && win.getSelection(); | ||
|
|
||
| if (!selection || selection.rangeCount === 0) { | ||
|
|
@@ -155,12 +153,12 @@ export function getModernOffsetsFromPoints( | |
| */ | ||
| export function setOffsets(node, offsets) { | ||
| const doc = node.ownerDocument || document; | ||
|
|
||
| if (!doc.defaultView.getSelection) { | ||
| const win = doc ? doc.defaultView : window; | ||
| if (!win.getSelection) { | ||
|
||
| return; | ||
| } | ||
|
|
||
| const selection = doc.defaultView.getSelection(); | ||
| const selection = win.getSelection(); | ||
| const length = node[getTextContentAccessor()].length; | ||
| let start = Math.min(offsets.start, length); | ||
| let end = offsets.end === undefined ? start : Math.min(offsets.end, length); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -65,10 +65,8 @@ function getSelection(node) { | |
| end: node.selectionEnd, | ||
| }; | ||
| } else { | ||
| let win = window; | ||
| if (node.ownerDocument && node.ownerDocument.defaultView) { | ||
| win = node.ownerDocument.defaultView; | ||
| } | ||
| const win = | ||
| (node.ownerDocument && node.ownerDocument.defaultView) || window; | ||
| if (win.getSelection) { | ||
|
||
| const selection = win.getSelection(); | ||
| return { | ||
|
|
||

There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: let's not read
ownerDocumenttwice. Put it in a variable.