MCPcopy Create free account
hub / github.com/bigskysoftware/_hyperscript / init

Method init

www/js/_hyperscript-max.js:3760–3795  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

3758 this.hyperscript = hyperscript;
3759 }
3760 init() {
3761 var self2 = this;
3762 var globalScope2 = this.globalScope;
3763 var _hyperscript2 = this.hyperscript;
3764 globalScope2.document.addEventListener("htmx:load", function(evt) {
3765 self2.#processingFromHtmx = true;
3766 _hyperscript2.process(evt.detail.elt);
3767 self2.#processingFromHtmx = false;
3768 });
3769 globalScope2.document.addEventListener("htmx:after:process", function(evt) {
3770 self2.#processingFromHtmx = true;
3771 _hyperscript2.process(evt.target);
3772 self2.#processingFromHtmx = false;
3773 });
3774 if (typeof globalScope2.htmx?.process === "function") {
3775 _hyperscript2.addAfterProcessHook(function(elt) {
3776 if (!self2.#processingFromHtmx) htmx.process(elt);
3777 });
3778 if (htmx.version?.startsWith("4")) {
3779 htmx.registerExtension("hs-include", {
3780 htmx_config_request: function(elt, detail) {
3781 var ctx = detail?.ctx;
3782 if (!ctx) return;
3783 var sourceElt = ctx.sourceElement || elt;
3784 var found = _HtmxCompat.#findHsInclude(sourceElt);
3785 if (!found) return;
3786 var vars = _HtmxCompat.#resolveSpecifiers(found.value, found.scopeElt);
3787 var body = ctx.request?.body;
3788 if (body instanceof FormData) {
3789 for (var k in vars) body.set(k, vars[k]);
3790 }
3791 }
3792 });
3793 }
3794 }
3795 }
3796 // ----- hs-include helpers -----
3797 static #findHsInclude(sourceElt) {
3798 var attr = sourceElt.getAttribute("hs-include");

Callers 1

Calls 4

addAfterProcessHookMethod · 0.45
#findHsIncludeMethod · 0.45
#resolveSpecifiersMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected