-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Extensibility: Apply filters without function wrappers #3933
Conversation
@@ -6,41 +6,31 @@ import { noop } from 'lodash'; | |||
/** | |||
* WordPress dependencies | |||
*/ | |||
import { applyFilters, removeAllFilters } from '@wordpress/hooks'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So the downside to this approach is that we can't clean up lingering handlers after tests?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test files are isolated, so they should be cleaned up anyways. I hope 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test files are isolated, so they should be cleaned up anyways. I hope 😄
Hmm, the require cache is cleared between each? Would be (good) news to me if true.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it isn’t the case only for mocks imported in Jest setup file.
You can enable reseting modules per test using resetModules config option or call it programmatically with the method called the same.
@aduth should I proceed with this PR? Let me know if you like it more? I'm convinced :) |
Description
Raised by @aduth when working on converting all filters for the components to work as HOCs (#3827 (comment)):
This PR explores if we can avoid exporting functions that enable filters for blocks. Instead we apply them directly in the same file when corresponding callbacks are defined.
How Has This Been Tested?
Unit tested.
Types of changes
Refactoring.
Checklist: