Comparing version 1.0.6 to 1.0.7
{ | ||
"name": "inframejs", | ||
"version": "1.0.6", | ||
"version": "1.0.7", | ||
"description": "use pure Javascript to connect the iframe pages", | ||
@@ -5,0 +5,0 @@ "main": "dist/inframejs.es.min.js", |
@@ -53,3 +53,3 @@ import {version} from '../package.json' | ||
if (typeof target === 'string') { | ||
this.target = document.querySelector(target); | ||
this.target = document.querySelector(target) | ||
} else if (typeof target !== 'undefined') { | ||
@@ -60,2 +60,3 @@ this.target = target | ||
} | ||
} | ||
@@ -92,21 +93,27 @@ | ||
this.logger(`${eventName} has been emit::${JSON.stringify(msg)}`) | ||
if(this.isConneted){ | ||
if(this.isSubPage){ | ||
// 子页面 | ||
if(this.isNewWindow){ | ||
window.opener.postMessage(msg,'*') | ||
try { | ||
if(this.isConneted){ | ||
if(this.isSubPage){ | ||
// 子页面 | ||
if(this.isNewWindow){ | ||
window.opener.postMessage(msg,'*') | ||
} else { | ||
window.parent.postMessage(msg,'*') | ||
} | ||
} else { | ||
window.parent.postMessage(msg,'*') | ||
// 主页面通过window.open打开了 | ||
if(this.isNewWindow){ | ||
this.target.postMessage(msg,'*') | ||
} else { | ||
this.target.contentWindow.postMessage(msg,'*') | ||
} | ||
} | ||
} else { | ||
// 主页面通过window.open打开了 | ||
if(this.isNewWindow){ | ||
this.target.postMessage(msg,'*') | ||
} else { | ||
this.target.contentWindow.postMessage(msg,'*') | ||
} | ||
this.emitCache.push({eventName, data}) | ||
} | ||
} else { | ||
this.emitCache.push({eventName, data}) | ||
} catch (e){ | ||
this.logger(e.message) | ||
this.destroy() | ||
} | ||
} | ||
@@ -125,3 +132,3 @@ | ||
if (this.whiteList.length) { | ||
const checked = this.whiteList.some(domain => ~domain.indexOf(e.origin)) | ||
const checked = this.whiteList.some(domain => domain.indexOf(e.origin) > -1) | ||
if (!checked) { | ||
@@ -128,0 +135,0 @@ console.warn('you are not access to inframe') |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
14740
344