Skip to content

Commit

Permalink
Add patch for the build file which is used by jest.
Browse files Browse the repository at this point in the history
  • Loading branch information
kuasha420 committed May 26, 2024
1 parent 01535fc commit a832b5f
Showing 1 changed file with 79 additions and 0 deletions.
79 changes: 79 additions & 0 deletions patches/@wordpress+data+4.27.3.patch
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,82 @@ index 1c11195..6f8cec8 100644
}
//# sourceMappingURL=index.js.map
\ No newline at end of file
diff --git a/node_modules/@wordpress/data/build/components/use-select/index.js b/node_modules/@wordpress/data/build/components/use-select/index.js
index 76e8a7a..0992fde 100644
--- a/node_modules/@wordpress/data/build/components/use-select/index.js
+++ b/node_modules/@wordpress/data/build/components/use-select/index.js
@@ -137,10 +137,7 @@ function useSelect(_mapSelect, deps) {
var isMountedAndNotUnsubscribing = (0, _element.useRef)(); // Keep track of the stores being selected in the mapSelect function,
// and only subscribe to those stores later.

- var listeningStores = (0, _element.useRef)([]);
- var trapSelect = (0, _element.useCallback)(function (callback) {
- return registry.__experimentalMarkListeningStores(callback, listeningStores);
- }, [registry]); // Generate a "flag" for used in the effect dependency array.
+ // Generate a "flag" for used in the effect dependency array.
// It's different than just using `mapSelect` since deps could be undefined,
// in that case, we would still want to memoize it.

@@ -152,9 +149,7 @@ function useSelect(_mapSelect, deps) {
if (!isWithoutMapping) {
try {
if (latestMapSelect.current !== mapSelect || latestMapOutputError.current) {
- mapOutput = trapSelect(function () {
- return mapSelect(registry.select, registry);
- });
+ mapOutput = mapSelect( registry.select, registry );
} else {
mapOutput = latestMapOutput.current;
}
@@ -199,9 +194,10 @@ function useSelect(_mapSelect, deps) {
var onStoreChange = function onStoreChange() {
if (isMountedAndNotUnsubscribing.current) {
try {
- var newMapOutput = trapSelect(function () {
- return latestMapSelect.current(registry.select, registry);
- });
+ var newMapOutput = latestMapSelect.current(
+ registry.select,
+ registry
+ );

if ((0, _isShallowEqual.default)(latestMapOutput.current, newMapOutput)) {
return;
@@ -224,26 +220,22 @@ function useSelect(_mapSelect, deps) {
onStoreChange();
}

- var onChange = function onChange() {
- if (latestIsAsync.current) {
- renderQueue.add(queueContext, onStoreChange);
- } else {
- onStoreChange();
- }
- };
+ var unsubscribe = registry.subscribe( () => {
+ if ( latestIsAsync.current ) {
+ renderQueue.add( queueContext, onStoreChange );
+ } else {
+ onStoreChange();
+ }
+ } );

- var unsubscribers = listeningStores.current.map(function (storeName) {
- return registry.__experimentalSubscribeStore(storeName, onChange);
- });
return function () {
isMountedAndNotUnsubscribing.current = false; // The return value of the subscribe function could be undefined if the store is a custom generic store.

- unsubscribers.forEach(function (unsubscribe) {
- return unsubscribe === null || unsubscribe === void 0 ? void 0 : unsubscribe();
- });
+ unsubscribe();
+
renderQueue.flush(queueContext);
};
- }, [registry, trapSelect, depsChangedFlag, isWithoutMapping]);
+ }, [registry, depsChangedFlag, isWithoutMapping]);
return isWithoutMapping ? registry.select(_mapSelect) : mapOutput;
}
//# sourceMappingURL=index.js.map
\ No newline at end of file

0 comments on commit a832b5f

Please sign in to comment.