UNPKG

@ionic/core

Version:
4 lines 1.5 kB
/*! * (C) Ionic http://ionicframework.com - MIT License */ import{c as e}from"./p-C-Cct-6D.js";const t=async(t,o,i,n,r,s)=>{var a;if(t)return t.attachViewToDom(o,i,r,n);if(!(s||"string"==typeof i||i instanceof HTMLElement))throw new Error("framework delegate is missing");const c="string"==typeof i?null===(a=o.ownerDocument)||void 0===a?void 0:a.createElement(i):i;return n&&n.forEach((e=>c.classList.add(e))),r&&Object.assign(c,r),o.appendChild(c),await new Promise((t=>e(c,t))),c},o=(e,t)=>{if(t){if(e)return e.removeViewFromDom(t.parentElement,t);t.remove()}return Promise.resolve()},i=()=>{let t,o;return{attachViewToDom:async(i,n,r={},s=[])=>{var a,c;let l;if(t=i,n){const o="string"==typeof n?null===(a=t.ownerDocument)||void 0===a?void 0:a.createElement(n):n;s.forEach((e=>o.classList.add(e))),Object.assign(o,r),t.appendChild(o),l=o,await new Promise((t=>e(o,t)))}else if(t.children.length>0&&("ION-MODAL"===t.tagName||"ION-POPOVER"===t.tagName)&&!(l=t.children[0]).classList.contains("ion-delegate-host")){const e=null===(c=t.ownerDocument)||void 0===c?void 0:c.createElement("div");e.classList.add("ion-delegate-host"),s.forEach((t=>e.classList.add(t))),e.append(...t.children),t.appendChild(e),l=e}const m=document.querySelector("ion-app")||document.body;return o=document.createComment("ionic teleport"),t.parentNode.insertBefore(o,t),m.appendChild(t),null!=l?l:t},removeViewFromDom:()=>(t&&o&&(o.parentNode.insertBefore(t,o),o.remove()),Promise.resolve())}};export{i as C,t as a,o as d}