Skip to content

Commit eea71cc

Browse files
committed
Merge branch 'branch-4a935922'
2 parents 5c49d9a + 8c68347 commit eea71cc

File tree

1 file changed

+12
-21
lines changed

1 file changed

+12
-21
lines changed

packages/sort/src/index.js

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import Sortable from 'sortablejs'
22
import { walk } from '../../alpinejs/src/utils/walk'
33

44
export default function (Alpine) {
5-
Alpine.directive('sort', (el, { value, modifiers, expression }, { effect, evaluate, evaluateLater, cleanup }) => {
5+
Alpine.directive('sort', (el, { value, modifiers, expression }, { effect, evaluate, cleanup }) => {
66
if (value === 'config') {
77
return // This will get handled by the main directive...
88
}
@@ -30,7 +30,7 @@ export default function (Alpine) {
3030
group: getGroupName(el, modifiers),
3131
}
3232

33-
let handleSort = generateSortHandler(expression, evaluateLater)
33+
let handleSort = generateSortHandler(expression, evaluate)
3434

3535
let config = getConfigurationOverrides(el, modifiers, evaluate)
3636

@@ -42,29 +42,20 @@ export default function (Alpine) {
4242
})
4343
}
4444

45-
function generateSortHandler(expression, evaluateLater) {
45+
function generateSortHandler(expression, evaluate) {
4646
// No handler was passed to x-sort...
4747
if ([undefined, null, ''].includes(expression)) return () => {}
4848

49-
let handle = evaluateLater(expression)
50-
5149
return (key, position) => {
52-
// In the case of `x-sort="handleSort"`, let us call it manually...
53-
Alpine.dontAutoEvaluateFunctions(() => {
54-
handle(
55-
// If a function is returned, call it with the key/position params...
56-
received => {
57-
if (typeof received === 'function') received(key, position)
58-
},
59-
// Provide $key and $position to the scope in case they want to call their own function...
60-
{ scope: {
61-
// Supporting both `$item` AND `$key` ($key for BC)...
62-
$key: key,
63-
$item: key,
64-
$position: position,
65-
} },
66-
)
67-
})
50+
evaluate(expression, { scope: {
51+
// Supporting both `$item` AND `$key` ($key for BC)...
52+
$key: key,
53+
$item: key,
54+
$position: position,
55+
}, params: [
56+
key,
57+
position
58+
] })
6859
}
6960
}
7061

0 commit comments

Comments
 (0)