Skip to content

Commit

Permalink
Update to Alpine 3.10.3
Browse files Browse the repository at this point in the history
  • Loading branch information
bep committed Jul 21, 2022
1 parent 99f542f commit 9446184
Show file tree
Hide file tree
Showing 60 changed files with 1,935 additions and 408 deletions.
95 changes: 58 additions & 37 deletions alpinejs/packages/alpinejs/dist/cdn.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand All @@ -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,
Expand Down Expand Up @@ -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]) => {
Expand All @@ -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 = {};
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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);
Expand All @@ -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;
}
Expand Down Expand Up @@ -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 = () => {
Expand Down
4 changes: 2 additions & 2 deletions alpinejs/packages/alpinejs/dist/cdn.min.js

Large diffs are not rendered by default.

95 changes: 58 additions & 37 deletions alpinejs/packages/alpinejs/dist/module.cjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -1796,8 +1796,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);
});
Expand Down Expand Up @@ -1912,8 +1927,7 @@ var directiveOrder = [
"show",
"if",
DEFAULT,
"teleport",
"element"
"teleport"
];
function byPriority(a, b) {
let typeA = directiveOrder.indexOf(a.type) === -1 ? DEFAULT : a.type;
Expand Down Expand Up @@ -2258,9 +2272,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();
Expand All @@ -2281,7 +2294,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,
Expand Down Expand Up @@ -2645,8 +2658,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]) => {
Expand All @@ -2660,6 +2678,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 = {};
Expand Down Expand Up @@ -2694,7 +2732,7 @@ var Alpine = {
get raw() {
return raw;
},
version: "3.10.2",
version: "3.10.3",
flushAndStopDeferringMutations,
dontAutoEvaluateFunctions,
disableEffectScheduling,
Expand Down Expand Up @@ -3169,7 +3207,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);
Expand All @@ -3180,31 +3224,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;
}
Expand Down Expand Up @@ -3239,7 +3258,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 = () => {
Expand Down
Loading

0 comments on commit 9446184

Please sign in to comment.