From 628d51f40222ec30c990f67bcfa264f25d68b721 Mon Sep 17 00:00:00 2001 From: Caleb Porzio Date: Wed, 27 Mar 2024 10:23:27 -0400 Subject: [PATCH] fix (#4111) --- packages/alpinejs/src/directives/x-bind.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/alpinejs/src/directives/x-bind.js b/packages/alpinejs/src/directives/x-bind.js index 92a33e145..947d0f837 100644 --- a/packages/alpinejs/src/directives/x-bind.js +++ b/packages/alpinejs/src/directives/x-bind.js @@ -6,7 +6,7 @@ import { applyBindingsObject, injectBindingProviders } from '../binds' mapAttributes(startingWith(':', into(prefix('bind:')))) -let handler = (el, { value, modifiers, expression, original }, { effect }) => { +let handler = (el, { value, modifiers, expression, original }, { effect, cleanup }) => { if (! value) { let bindingProviders = {} injectBindingProviders(bindingProviders) @@ -36,6 +36,11 @@ let handler = (el, { value, modifiers, expression, original }, { effect }) => { mutateDom(() => bind(el, value, result, modifiers)) })) + + cleanup(() => { + el._x_undoAddedClasses && el._x_undoAddedClasses() + el._x_undoAddedStyles && el._x_undoAddedStyles() + }) } // @todo: see if I can take advantage of the object created here inside the