-
Notifications
You must be signed in to change notification settings - Fork 50.2k
Support iframes (nested browsing contexts) in selection event handling #9184
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
e1d4110
ed0cc8a
8f11b2c
83cfb55
374d525
f6f9e35
6ac703f
cec8c3f
0163795
d777546
7c59a77
131357e
2d4ac46
5755556
b3998eb
174375c
39a9589
82443f7
b25279d
026e8f0
689d7c1
074ff51
0744710
c71601b
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 |
|---|---|---|
|
|
@@ -15,9 +15,11 @@ var SyntheticEvent = require('events/SyntheticEvent'); | |
| */ | ||
| var ClipboardEventInterface = { | ||
| clipboardData: function(event) { | ||
| return 'clipboardData' in event | ||
| ? event.clipboardData | ||
| : window.clipboardData; | ||
| if ('clipboardData' in event) { | ||
| return event.clipboardData; | ||
| } | ||
| var doc = (event.target && event.target.ownerDocument) || document; | ||
| return doc.defaultView.clipboardData; | ||
| }, | ||
| }; | ||
|
||
|
|
||
|
|
||
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.
When is ownerDocument ever undefined?
Uh oh!
There was an error while loading. Please reload this page.
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.
According to the MDN page about the
Nodeinterface:That doesn’t refer to a node that isn’t in the DOM, which will still have a reference to the
ownerDocumentwhere it originated (viadocument.createElement). In my experience,ownerDocumentis onlynullforDocumentnodes themselves, which matches what MDN says on the page specifically aboutNode.ownerDocument:So now that you mention it, this check could be updated to handle
Documentspecifically, maybe likevar doc = node.nodeType === 9 ? node : node.ownerDocument;However, maybe
ownerDocumentcould also benullif, for example, you had a reference to a node from a document that has since been destroyed (an iframe element that got removed from the DOM and garbage collected, for example)? I’m not sure. Hence the simplified fallback to the global document wheneverownerDocumentisn’t truthy.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.
Cool. Thank you. That was extremely helpful!