Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@daun
Copy link
Member

@daun daun commented Sep 26, 2024

Description

  • The once option is currently ignored when replacing an internal hook handler
  • This fix allows combinations of once and replace

Checks

  • The PR is submitted to the master branch
  • The code was linted before pushing (npm run lint)
  • All tests are passing (npm run test)
  • New or updated tests are included
  • The documentation was updated as required

@github-actions
Copy link

Size Change: +30 B (+0.13%)

Total Size: 23.4 kB

Filename Size Change
dist/Swup.modern.js 7.11 kB +9 B (+0.13%)
dist/Swup.module.js 8.03 kB +10 B (+0.12%)
dist/Swup.umd.js 8.27 kB +11 B (+0.13%)

compressed-size-action

@daun daun requested a review from a team September 26, 2024 21:05
@github-actions
Copy link

Playwright test results

passed  309 passed

Details

report  Open report ↗︎
stats  309 tests across 22 suites
duration  1 minute, 18 seconds
commit  44bf30b

@hirasso
Copy link
Member

hirasso commented Sep 27, 2024

Nice! I don't know if its a no brainer anyways, but just to make sure: will this also work with

swup.hooks.replace('enable', () => {}, {once: true});

?

@daun
Copy link
Member Author

daun commented Sep 27, 2024

@hirasso Yes, that'll work. The replace (and before and once) methods on the hooks registry passes along any other options. So for example hooks.replace looks like this:

replace(hook, handler, options = {}) {
  return this.on(hook, handler, { ...options, replace: true })
}

@daun daun merged commit 1550d9f into master Sep 28, 2024
23 checks passed
@daun daun deleted the fix/hooks-replaced-once branch September 28, 2024 12:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants