[fix] support 'mailto:' URLs in 'Linking'

This commit is contained in:
Nicolas Gallagher
2017-04-21 18:29:29 -07:00
parent 046e01dfa9
commit 9012e98ba7
+2 -1
View File
@@ -28,6 +28,7 @@ const Linking = {
* https://mathiasbynens.github.io/rel-noopener/
*/
const iframeOpen = url => {
const noOpener = url.indexOf('mailto:') !== 0;
const iframe = document.createElement('iframe');
iframe.style.display = 'none';
document.body.appendChild(iframe);
@@ -36,7 +37,7 @@ const iframeOpen = url => {
const script = iframeDoc.createElement('script');
script.text = `
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);
document.body.removeChild(iframe);