Skip to content

Commit

Permalink
Further fixes for cross-iframe compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
acusti committed Nov 1, 2017
1 parent 4875d01 commit 1dd8abb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
11 changes: 4 additions & 7 deletions packages/react-dom/src/client/ReactDOMSelection.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,16 +157,13 @@ function getModernOffsetsFromPoints(
* @param {object} offsets
*/
function setModernOffsets(node, offsets) {
var win = window;
if (node.ownerDocument && node.ownerDocument.defaultView) {
win = node.ownerDocument.defaultView;
}
var doc = node.ownerDocument || document;

if (!win.getSelection) {
if (!doc.defaultView.getSelection) {
return;
}

var selection = win.getSelection();
var selection = doc.defaultView.getSelection();
var length = node[getTextContentAccessor()].length;
var start = Math.min(offsets.start, length);
var end = offsets.end === undefined ? start : Math.min(offsets.end, length);
Expand All @@ -192,7 +189,7 @@ function setModernOffsets(node, offsets) {
) {
return;
}
var range = document.createRange();
var range = doc.createRange();
range.setStart(startMarker.node, startMarker.offset);
selection.removeAllRanges();

Expand Down
8 changes: 5 additions & 3 deletions packages/react-dom/src/events/SyntheticClipboardEvent.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
},
};

Expand Down

0 comments on commit 1dd8abb

Please sign in to comment.