Caleb Porzio 1 year ago
parent
commit
628d51f402
1 changed files with 6 additions and 1 deletions
  1. 6 1
      packages/alpinejs/src/directives/x-bind.js

+ 6 - 1
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