Skip to content

Commit

Permalink
Preserve this context on lifecycle methods
Browse files Browse the repository at this point in the history
  • Loading branch information
hopsoft committed Oct 4, 2019
1 parent 639b55d commit 673ab4c
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions javascript/stimulus_reflex.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,19 @@ const invokeLifecycleMethod = (stage, reflex, element) => {
const genericLifecycleMethod = controller[genericLifecycleMethodName]

if (typeof specificLifecycleMethod === 'function') {
setTimeout(() => specificLifecycleMethod(element, element.reflexError), 1)
setTimeout(
() =>
specificLifecycleMethod.call(controller, element, element.reflexError),
1
)
}

if (typeof genericLifecycleMethod === 'function') {
setTimeout(() => genericLifecycleMethod(element, element.reflexError), 1)
setTimeout(
() =>
genericLifecycleMethod.call(controller, element, element.reflexError),
1
)
}
}

Expand Down

0 comments on commit 673ab4c

Please sign in to comment.