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

Method init

www/js/_hyperscript.js:3761–3796  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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

Callers 1

_hyperscript.jsFile · 0.45

Calls 4

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

Tested by

no test coverage detected