mirror of
https://github.com/zoriya/react-native-web.git
synced 2026-05-31 09:44:21 +00:00
[fix] support 'mailto:' URLs in 'Linking'
This commit is contained in:
@@ -28,6 +28,7 @@ const Linking = {
|
|||||||
* https://mathiasbynens.github.io/rel-noopener/
|
* https://mathiasbynens.github.io/rel-noopener/
|
||||||
*/
|
*/
|
||||||
const iframeOpen = url => {
|
const iframeOpen = url => {
|
||||||
|
const noOpener = url.indexOf('mailto:') !== 0;
|
||||||
const iframe = document.createElement('iframe');
|
const iframe = document.createElement('iframe');
|
||||||
iframe.style.display = 'none';
|
iframe.style.display = 'none';
|
||||||
document.body.appendChild(iframe);
|
document.body.appendChild(iframe);
|
||||||
@@ -36,7 +37,7 @@ const iframeOpen = url => {
|
|||||||
const script = iframeDoc.createElement('script');
|
const script = iframeDoc.createElement('script');
|
||||||
script.text = `
|
script.text = `
|
||||||
window.parent = null; window.top = null; window.frameElement = null;
|
window.parent = null; window.top = null; window.frameElement = null;
|
||||||
var child = window.open("${url}"); child.opener = null;
|
var child = window.open("${url}"); ${noOpener && 'child.opener = null'};
|
||||||
`;
|
`;
|
||||||
iframeDoc.body.appendChild(script);
|
iframeDoc.body.appendChild(script);
|
||||||
document.body.removeChild(iframe);
|
document.body.removeChild(iframe);
|
||||||
|
|||||||
Reference in New Issue
Block a user