diff options
Diffstat (limited to 'alpinejs/packages/csp/dist/module.esm.js')
-rw-r--r-- | alpinejs/packages/csp/dist/module.esm.js | 95 |
1 files changed, 58 insertions, 37 deletions
diff --git a/alpinejs/packages/csp/dist/module.esm.js b/alpinejs/packages/csp/dist/module.esm.js index 40eaee2..607b18f 100644 --- a/alpinejs/packages/csp/dist/module.esm.js +++ b/alpinejs/packages/csp/dist/module.esm.js @@ -530,8 +530,23 @@ function directive(name, callback) { 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); }); @@ -646,8 +661,7 @@ var directiveOrder = [ "show", "if", DEFAULT, - "teleport", - "element" + "teleport" ]; function byPriority(a, b) { let typeA = directiveOrder.indexOf(a.type) === -1 ? DEFAULT : a.type; @@ -992,9 +1006,8 @@ function registerTransitionObject(el, setFunction, defaultValue = {}) { }; } 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(); @@ -1015,7 +1028,7 @@ window.Element.prototype._x_toggleAndCascadeWithTransitions = function(el, value closest._x_hideChildren = []; closest._x_hideChildren.push(el); } else { - queueMicrotask(() => { + nextTick2(() => { let hideAfterChildren = (el2) => { let carry = Promise.all([ el2._x_hidePromise, @@ -1379,8 +1392,13 @@ function getStores() { // 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]) => { @@ -1394,6 +1412,26 @@ function injectBindingProviders(obj) { }); 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 = {}; @@ -1428,7 +1466,7 @@ var Alpine = { get raw() { return raw; }, - version: "3.10.2", + version: "3.10.3", flushAndStopDeferringMutations, dontAutoEvaluateFunctions, disableEffectScheduling, @@ -2579,7 +2617,13 @@ directive("html", (el, {expression}, {effect: effect3, evaluateLater: evaluateLa 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); @@ -2590,31 +2634,6 @@ directive("bind", (el, {value, modifiers, expression, original}, {effect: effect 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; } @@ -2649,7 +2668,9 @@ directive("show", (el, {modifiers, expression}, {effect: effect3}) => { 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 = () => { |