|
|
@ -270,9 +270,11 @@ export function add_resize_listener(node: HTMLElement, fn: () => void) {
|
|
|
|
iframe.setAttribute('aria-hidden', 'true');
|
|
|
|
iframe.setAttribute('aria-hidden', 'true');
|
|
|
|
iframe.tabIndex = -1;
|
|
|
|
iframe.tabIndex = -1;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const crossorigin = is_crossorigin();
|
|
|
|
|
|
|
|
|
|
|
|
let unsubscribe: () => void;
|
|
|
|
let unsubscribe: () => void;
|
|
|
|
|
|
|
|
|
|
|
|
if (is_crossorigin()) {
|
|
|
|
if (crossorigin) {
|
|
|
|
iframe.src = `data:text/html,<script>onresize=function(){parent.postMessage(0,'*')}</script>`;
|
|
|
|
iframe.src = `data:text/html,<script>onresize=function(){parent.postMessage(0,'*')}</script>`;
|
|
|
|
unsubscribe = listen(window, 'message', (event: MessageEvent) => {
|
|
|
|
unsubscribe = listen(window, 'message', (event: MessageEvent) => {
|
|
|
|
if (event.source === iframe.contentWindow) fn();
|
|
|
|
if (event.source === iframe.contentWindow) fn();
|
|
|
@ -287,8 +289,13 @@ export function add_resize_listener(node: HTMLElement, fn: () => void) {
|
|
|
|
append(node, iframe);
|
|
|
|
append(node, iframe);
|
|
|
|
|
|
|
|
|
|
|
|
return () => {
|
|
|
|
return () => {
|
|
|
|
|
|
|
|
if (crossorigin) {
|
|
|
|
|
|
|
|
unsubscribe();
|
|
|
|
|
|
|
|
} else if (unsubscribe && iframe.contentWindow) {
|
|
|
|
|
|
|
|
unsubscribe();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
detach(iframe);
|
|
|
|
detach(iframe);
|
|
|
|
if (unsubscribe) unsubscribe();
|
|
|
|
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|