Skip to content

Commit

Permalink
Expose a hook for added attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
calebporzio committed Jul 29, 2023
1 parent 2337eac commit 98a0fff
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
3 changes: 2 additions & 1 deletion packages/alpinejs/src/alpine.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { setReactivityEngine, disableEffectScheduling, reactive, effect, release, raw } from './reactivity'
import { mapAttributes, directive, setPrefix as prefix, prefix as prefixed } from './directives'
import { start, addRootSelector, addInitSelector, closestRoot, findClosest, initTree, destroyTree, interceptInit } from './lifecycle'
import { onElRemoved, onAttributeRemoved, mutateDom, deferMutations, flushAndStopDeferringMutations, startObservingMutations, stopObservingMutations } from './mutation'
import { onElRemoved, onAttributeRemoved, onAttributesAdded, mutateDom, deferMutations, flushAndStopDeferringMutations, startObservingMutations, stopObservingMutations } from './mutation'
import { mergeProxies, closestDataStack, addScopeToNode, scope as $data } from './scope'
import { setEvaluator, evaluate, evaluateLater, dontAutoEvaluateFunctions } from './evaluator'
import { transition } from './directives/x-transition'
Expand Down Expand Up @@ -33,6 +33,7 @@ let Alpine = {
stopObservingMutations,
setReactivityEngine,
onAttributeRemoved,
onAttributesAdded,
closestDataStack,
skipDuringClone,
onlyDuringClone,
Expand Down
8 changes: 7 additions & 1 deletion packages/alpinejs/src/binds.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ export function bind(name, bindings) {
let getBindings = typeof bindings !== 'function' ? () => bindings : bindings

if (name instanceof Element) {
applyBindingsObject(name, getBindings())
return applyBindingsObject(name, getBindings())
} else {
binds[name] = getBindings
}

return () => {} // Null cleanup...
}

export function injectBindingProviders(obj) {
Expand Down Expand Up @@ -58,4 +60,8 @@ export function applyBindingsObject(el, obj, original) {

handle()
})

return () => {
while (cleanupRunners.length) cleanupRunners.pop()()
}
}

0 comments on commit 98a0fff

Please sign in to comment.