diff options
Diffstat (limited to 'alpinejs/packages/csp/dist/cdn.js')
-rw-r--r-- | alpinejs/packages/csp/dist/cdn.js | 95 |
1 files changed, 58 insertions, 37 deletions
diff --git a/alpinejs/packages/csp/dist/cdn.js b/alpinejs/packages/csp/dist/cdn.js index 8599847..2cba335 100644 --- a/alpinejs/packages/csp/dist/cdn.js +++ b/alpinejs/packages/csp/dist/cdn.js @@ -531,8 +531,23 @@ ${expression ? 'Expression: "' + expression + '"\n\n' : ""}`, el); directiveHandlers[name] = callback; } function directives(el, attributes, originalAttributeOverride) { + attributes = Array.from(attributes); + if (el._x_virtualDirectives) { + let vAttributes = Object.entries(el._x_virtualDirectives).map(([name, value]) => ({name, value})); + let staticAttributes = attributesOnly(vAttributes); + vAttributes = vAttributes.map((attribute) => { + if (staticAttributes.find((attr) => attr.name === attribute.name)) { + return { + name: `x-bind:${attribute.name}`, + value: `"${attribute.value}"` + }; + } + return attribute; + }); + attributes = attributes.concat(vAttributes); + } let transformedAttributeMap = {}; - let directives2 = Array.from(attributes).map(toTransformedAttributes((newName, oldName) => transformedAttributeMap[newName] = oldName)).filter(outNonAlpineAttributes).map(toParsedDirectives(transformedAttributeMap, originalAttributeOverride)).sort(byPriority); + let directives2 = attributes.map(toTransformedAttributes((newName, oldName) => transformedAttributeMap[newName] = oldName)).filter(outNonAlpineAttributes).map(toParsedDirectives(transformedAttributeMap, originalAttributeOverride)).sort(byPriority); return directives2.map((directive2) => { return getDirectiveHandler(el, directive2); }); @@ -647,8 +662,7 @@ ${expression ? 'Expression: "' + expression + '"\n\n' : ""}`, el); "show", "if", DEFAULT, - "teleport", - "element" + "teleport" ]; function byPriority(a, b) { let typeA = directiveOrder.indexOf(a.type) === -1 ? DEFAULT : a.type; @@ -993,9 +1007,8 @@ ${expression ? 'Expression: "' + expression + '"\n\n' : ""}`, el); }; } window.Element.prototype._x_toggleAndCascadeWithTransitions = function(el, value, show, hide) { - let clickAwayCompatibleShow = () => { - document.visibilityState === "visible" ? requestAnimationFrame(show) : setTimeout(show); - }; + const nextTick2 = document.visibilityState === "visible" ? requestAnimationFrame : setTimeout; + let clickAwayCompatibleShow = () => nextTick2(show); if (value) { if (el._x_transition && (el._x_transition.enter || el._x_transition.leave)) { el._x_transition.enter && (Object.entries(el._x_transition.enter.during).length || Object.entries(el._x_transition.enter.start).length || Object.entries(el._x_transition.enter.end).length) ? el._x_transition.in(show) : clickAwayCompatibleShow(); @@ -1016,7 +1029,7 @@ ${expression ? 'Expression: "' + expression + '"\n\n' : ""}`, el); closest._x_hideChildren = []; closest._x_hideChildren.push(el); } else { - queueMicrotask(() => { + nextTick2(() => { let hideAfterChildren = (el2) => { let carry = Promise.all([ el2._x_hidePromise, @@ -1380,8 +1393,13 @@ ${expression ? 'Expression: "' + expression + '"\n\n' : ""}`, el); // packages/alpinejs/src/binds.js var binds = {}; - function bind2(name, object) { - binds[name] = typeof object !== "function" ? () => object : object; + function bind2(name, bindings) { + let getBindings = typeof bindings !== "function" ? () => bindings : bindings; + if (name instanceof Element) { + applyBindingsObject(name, getBindings()); + } else { + binds[name] = getBindings; + } } function injectBindingProviders(obj) { Object.entries(binds).forEach(([name, callback]) => { @@ -1395,6 +1413,26 @@ ${expression ? 'Expression: "' + expression + '"\n\n' : ""}`, el); }); return obj; } + function applyBindingsObject(el, obj, original) { + let cleanupRunners = []; + while (cleanupRunners.length) + cleanupRunners.pop()(); + let attributes = Object.entries(obj).map(([name, value]) => ({name, value})); + let staticAttributes = attributesOnly(attributes); + attributes = attributes.map((attribute) => { + if (staticAttributes.find((attr) => attr.name === attribute.name)) { + return { + name: `x-bind:${attribute.name}`, + value: `"${attribute.value}"` + }; + } + return attribute; + }); + directives(el, attributes, original).map((handle) => { + cleanupRunners.push(handle.runCleanups); + handle(); + }); + } // packages/alpinejs/src/datas.js var datas = {}; @@ -1429,7 +1467,7 @@ ${expression ? 'Expression: "' + expression + '"\n\n' : ""}`, el); get raw() { return raw; }, - version: "3.10.2", + version: "3.10.3", flushAndStopDeferringMutations, dontAutoEvaluateFunctions, disableEffectScheduling, @@ -2580,7 +2618,13 @@ ${expression ? 'Expression: "' + expression + '"\n\n' : ""}`, el); mapAttributes(startingWith(":", into(prefix("bind:")))); directive("bind", (el, {value, modifiers, expression, original}, {effect: effect3}) => { if (!value) { - return applyBindingsObject(el, expression, original, effect3); + let bindingProviders = {}; + injectBindingProviders(bindingProviders); + let getBindings = evaluateLater(el, expression); + getBindings((bindings) => { + applyBindingsObject(el, bindings, original); + }, {scope: bindingProviders}); + return; } if (value === "key") return storeKeyForXFor(el, expression); @@ -2591,31 +2635,6 @@ ${expression ? 'Expression: "' + expression + '"\n\n' : ""}`, el); mutateDom(() => bind(el, value, result, modifiers)); })); }); - function applyBindingsObject(el, expression, original, effect3) { - let bindingProviders = {}; - injectBindingProviders(bindingProviders); - let getBindings = evaluateLater(el, expression); - let cleanupRunners = []; - while (cleanupRunners.length) - cleanupRunners.pop()(); - getBindings((bindings) => { - let attributes = Object.entries(bindings).map(([name, value]) => ({name, value})); - let staticAttributes = attributesOnly(attributes); - attributes = attributes.map((attribute) => { - if (staticAttributes.find((attr) => attr.name === attribute.name)) { - return { - name: `x-bind:${attribute.name}`, - value: `"${attribute.value}"` - }; - } - return attribute; - }); - directives(el, attributes, original).map((handle) => { - cleanupRunners.push(handle.runCleanups); - handle(); - }); - }, {scope: bindingProviders}); - } function storeKeyForXFor(el, expression) { el._x_keyExpression = expression; } @@ -2650,7 +2669,9 @@ ${expression ? 'Expression: "' + expression + '"\n\n' : ""}`, el); let evaluate2 = evaluateLater(el, expression); if (!el._x_doHide) el._x_doHide = () => { - mutateDom(() => el.style.display = "none"); + mutateDom(() => { + el.style.setProperty("display", "none", modifiers.includes("important") ? "important" : void 0); + }); }; if (!el._x_doShow) el._x_doShow = () => { |