{ "version": 3, "sources": ["node_modules/imba/src/imba/dom/mount.imba"], "sourcesContent": ["import {renderContext} from './context'\nimport {scheduler} from '../scheduler'\n\nexport def render blk, ctx = {}\n\tlet prev = renderContext.context\n\trenderContext.context = ctx\n\tlet res = blk(ctx)\n\tif renderContext.context == ctx\n\t\trenderContext.context = prev\n\treturn res\n\nexport def mount mountable, into\n\tlet parent = into or global.document.body\n\tlet element = mountable\n\tif mountable isa Function\n\t\tlet ctx = {_: parent}\n\t\tlet tick = do\n\t\t\tlet prev = renderContext.context\n\t\t\trenderContext.context = ctx\n\t\t\tlet res = mountable(ctx)\n\t\t\tif renderContext.context == ctx\n\t\t\t\trenderContext.context = prev\n\t\t\treturn res\n\t\telement = tick()\n\t\tscheduler.listen('commit',tick)\n\telse\n\t\t# automatic scheduling of element - even before\n\t\t# element.__schedule = yes\n\t\telement.__F |= $EL_SCHEDULE$\n\n\telement.#insertInto(parent)\n\t# parent.appendChild(element)\n\treturn element\n\nexport def unmount el\n\tif el and el.#removeFrom\n\t\tel.#removeFrom(el.parentNode)\n\treturn el\n\t\t\nlet instance = global.imba ||= {}\ninstance.mount = mount\ninstance.unmount = unmount"], "mappings": ";oMAWO,WAAU,EAAW,EAAI,CAC3B,GAAA,GAAS,GAAQ,WAAO,SAAS,KACjC,EAAU,EACd,GAAG,YAAc,UAAQ,CACpB,GAAA,GAAM,CAAC,EAAG,GACV,EAAO,UAAE,CACR,GAAA,GAAO,EAAc,QACzB,EAAc,QAAU,EACpB,GAAA,GAAM,EAAU,GACpB,MAAG,GAAc,SAAW,GAC3B,GAAc,QAAU,GAClB,GACR,EAAU,IACV,EAAU,OAAO,SAAS,OAI1B,GAAQ,KAAO,GAEhB,SAAO,GAAa,GAEb,EAED,WAAY,EAAE,CACpB,MAAG,IAAO,EAAE,IACX,EAAE,GAAa,EAAG,YACZ,EAEJ,GAAA,GAAW,WAAO,MAAP,YAAO,KAAS,IAC/B,EAAS,MAAQ,EACjB,EAAS,QAAU", "names": [] }