@open-iframe-resizer/core 1.1.2 → 1.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +6 -3
- package/dist/index.umd.cjs +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -40,13 +40,16 @@ function I(e) {
|
|
|
40
40
|
}
|
|
41
41
|
return null;
|
|
42
42
|
}
|
|
43
|
-
const f = C()
|
|
43
|
+
const f = C();
|
|
44
|
+
let d = [];
|
|
45
|
+
const W = (e, n) => {
|
|
44
46
|
const t = { ...y(), ...O(e ?? {}) }, r = v(n), i = S(t, r);
|
|
45
47
|
return r.map((o) => {
|
|
46
|
-
|
|
48
|
+
d.push({ iframe: o, settings: t });
|
|
49
|
+
const c = R(o, t, i);
|
|
47
50
|
return {
|
|
48
51
|
unsubscribe: () => {
|
|
49
|
-
|
|
52
|
+
c(), d = d.filter((s) => s.iframe !== o);
|
|
50
53
|
}
|
|
51
54
|
};
|
|
52
55
|
});
|
package/dist/index.umd.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(s,c){typeof exports=="object"&&typeof module<"u"?c(exports):typeof define=="function"&&define.amd?define(["exports"],c):(s=typeof globalThis<"u"?globalThis:s||self,c(s.iframeResizer={}))})(this,function(s){"use strict";const c=()=>window&&window.self!==window.top,g=e=>e instanceof HTMLIFrameElement,y=(e,n)=>{e.document.readyState==="complete"?n():e.addEventListener("load",n)},p=(e,n)=>{n(),e.addEventListener("load",n)},L=(e,n)=>{var r,o;const t=((r=e.contentWindow)==null?void 0:r.document.readyState)==="complete";return e.src!=="about:blank"&&((o=e.contentWindow)==null?void 0:o.location.href)!=="about:blank"&&t?n():e.addEventListener("load",n)},w=()=>({offsetSize:0,checkOrigin:!0,enableLegacyLibSupport:!1}),O=e=>{try{return new URL(e.src).origin===window.location.origin}catch{return!1}},z=e=>{try{const n=new URL(e.src).origin;if(n!=="about:blank")return n}catch{}return null},I=e=>(Object.keys(e).forEach(n=>e[n]===void 0&&delete e[n]),e),m=e=>{const{height:n}=e.documentElement.getBoundingClientRect()??{};return n?Math.ceil(n):void 0};function v(e){p(e,()=>{var n;return(n=e.contentWindow)==null?void 0:n.postMessage("[iFrameSizer]ID:0:false:false:32:true:true::auto:::0:false:child:auto:true:::true:::false","*")})}function S(e){if(typeof e.data=="string"&&e.data.startsWith("[iFrameSizer]")){const[n,t]=e.data.split(":"),i=+t;return i>0?i:null}return null}const h=T()
|
|
1
|
+
(function(s,c){typeof exports=="object"&&typeof module<"u"?c(exports):typeof define=="function"&&define.amd?define(["exports"],c):(s=typeof globalThis<"u"?globalThis:s||self,c(s.iframeResizer={}))})(this,function(s){"use strict";const c=()=>window&&window.self!==window.top,g=e=>e instanceof HTMLIFrameElement,y=(e,n)=>{e.document.readyState==="complete"?n():e.addEventListener("load",n)},p=(e,n)=>{n(),e.addEventListener("load",n)},L=(e,n)=>{var r,o;const t=((r=e.contentWindow)==null?void 0:r.document.readyState)==="complete";return e.src!=="about:blank"&&((o=e.contentWindow)==null?void 0:o.location.href)!=="about:blank"&&t?n():e.addEventListener("load",n)},w=()=>({offsetSize:0,checkOrigin:!0,enableLegacyLibSupport:!1}),O=e=>{try{return new URL(e.src).origin===window.location.origin}catch{return!1}},z=e=>{try{const n=new URL(e.src).origin;if(n!=="about:blank")return n}catch{}return null},I=e=>(Object.keys(e).forEach(n=>e[n]===void 0&&delete e[n]),e),m=e=>{const{height:n}=e.documentElement.getBoundingClientRect()??{};return n?Math.ceil(n):void 0};function v(e){p(e,()=>{var n;return(n=e.contentWindow)==null?void 0:n.postMessage("[iFrameSizer]ID:0:false:false:32:true:true::auto:::0:false:child:auto:true:::true:::false","*")})}function S(e){if(typeof e.data=="string"&&e.data.startsWith("[iFrameSizer]")){const[n,t]=e.data.split(":"),i=+t;return i>0?i:null}return null}const h=T();let u=[];const R=(e,n)=>{const t={...w(),...I(e??{})},i=E(n),r=k(t,i);return i.map(o=>{u.push({iframe:o,settings:t});const f=C(o,t,r);return{unsubscribe:()=>{f(),u=u.filter(a=>a.iframe!==o)}}})};function E(e){return typeof e=="string"?Array.from(document.querySelectorAll(e)).filter(g):e?g(e)?[e]:[]:Array.from(document.getElementsByTagName("iframe"))}function k(e,n){if(Array.isArray(e.checkOrigin))return e.checkOrigin;if(!e.checkOrigin)return[];const t=[];for(const i of n){const r=z(i);r&&t.push(r)}return t}function C(e,n,t){return O(e)?M(e):D(e,n,t)}function D(e,n,t){const i=r=>{var a;const o=!n.checkOrigin||t.includes(r.origin);if(!(!(e.contentWindow===r.source)||!o)){if(((a=r.data)==null?void 0:a.type)==="iframe-resized"){const{height:d}=r.data;d&&l({height:d,iframe:e,settings:n});return}if(n.enableLegacyLibSupport){const d=S(r);d!==null&&l({height:d,iframe:e,settings:n});return}}};return window.addEventListener("message",i),n.enableLegacyLibSupport&&v(e),()=>window.removeEventListener("message",i)}function M(e){const n=()=>{var i;const t=(i=e.contentDocument)==null?void 0:i.body;if(!t){console.error("Unable to observe the iframe content document body");return}h.observe(t)};return L(e,n),()=>{var t;(t=e.contentDocument)!=null&&t.body&&h.unobserve(e.contentDocument.body),e.removeEventListener("load",n)}}function T(){const e=({target:n})=>{const t=u.find(f=>{var a;return((a=f.iframe.contentDocument)==null?void 0:a.body)===n});if(!t)return;const{iframe:i,settings:r}=t;if(!i.contentDocument)return;const o=m(i.contentDocument);o&&l({height:o,iframe:i,settings:r})};return new ResizeObserver(n=>n.forEach(e))}function l({height:e,iframe:n,settings:t}){n.style.height=`${e+t.offsetSize}px`}c()&&b();function b(){y(window,()=>{const e=()=>{const t={type:"iframe-resized",width:document.documentElement.scrollWidth,height:m(document)??void 0};window.parent.postMessage(t,"*")};new ResizeObserver(e).observe(document.body)})}s.initialize=R,s.initializeChildListener=b,Object.defineProperty(s,Symbol.toStringTag,{value:"Module"})});
|