UNPKG

836 BJavaScriptView Raw
1(function(){
2
3 function mergeObjects(obj1, obj2) {
4 for (var key in obj2) {
5 if (obj2.hasOwnProperty(key)) {
6 obj1[key] = obj2[key];
7 }
8 }
9 return obj1;
10 }
11
12 htmx.defineExtension('include-vals', {
13 onEvent: function (name, evt) {
14 if (name === "htmx:configRequest") {
15 var includeValsElt = htmx.closest(evt.detail.elt, "[include-vals],[data-include-vals]");
16 if (includeValsElt) {
17 var includeVals = includeValsElt.getAttribute("include-vals") || includeValsElt.getAttribute("data-include-vals");
18 var valuesToInclude = eval("({" + includeVals + "})");
19 mergeObjects(evt.detail.parameters, valuesToInclude);
20 }
21 }
22 }
23 });
24})();