Skip to content

Commit 31d35ab

Browse files
committed
add async clearHidden processor
1 parent 73a7882 commit 31d35ab

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

src/process/clearHidden/__tests__/clearHidden.test.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { expect } from 'chai';
22

3-
import { clearHiddenProcess } from '../index';
3+
import { clearHiddenProcessSync } from '../index';
44

55
describe('clearHidden', function () {
66
it('Shoud not clear conditionally hidden component data when clearOnHide is false', function () {
@@ -28,7 +28,7 @@ describe('clearHidden', function () {
2828
},
2929
path: 'foo',
3030
};
31-
clearHiddenProcess(context);
31+
clearHiddenProcessSync(context);
3232
expect(context.data).to.deep.equal({ foo: 'bar' });
3333
});
3434

@@ -57,7 +57,7 @@ describe('clearHidden', function () {
5757
},
5858
path: 'foo',
5959
};
60-
clearHiddenProcess(context);
60+
clearHiddenProcessSync(context);
6161
expect(context.data).to.deep.equal({});
6262
});
6363

@@ -81,7 +81,7 @@ describe('clearHidden', function () {
8181
},
8282
path: 'foo',
8383
};
84-
clearHiddenProcess(context);
84+
clearHiddenProcessSync(context);
8585
expect(context.data).to.deep.equal({ foo: 'bar' });
8686
});
8787
});

src/process/clearHidden/index.ts

+8-2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
ProcessorInfo,
66
ProcessorFnSync,
77
ConditionsScope,
8+
ProcessorFn,
89
} from 'types';
910

1011
type ClearHiddenScope = ProcessorScope & {
@@ -16,7 +17,7 @@ type ClearHiddenScope = ProcessorScope & {
1617
/**
1718
* This processor function checks components for the `hidden` property and unsets corresponding data
1819
*/
19-
export const clearHiddenProcess: ProcessorFnSync<ClearHiddenScope> = (context) => {
20+
export const clearHiddenProcessSync: ProcessorFnSync<ClearHiddenScope> = (context) => {
2021
const { component, data, value, scope, path } = context;
2122

2223
// No need to unset the value if it's undefined
@@ -45,8 +46,13 @@ export const clearHiddenProcess: ProcessorFnSync<ClearHiddenScope> = (context) =
4546
}
4647
};
4748

49+
export const clearHiddenProcess: ProcessorFn<ClearHiddenScope> = async (context) => {
50+
return clearHiddenProcessSync(context);
51+
};
52+
4853
export const clearHiddenProcessInfo: ProcessorInfo<ProcessorContext<ClearHiddenScope>, void> = {
4954
name: 'clearHidden',
5055
shouldProcess: () => true,
51-
processSync: clearHiddenProcess,
56+
process: clearHiddenProcess,
57+
processSync: clearHiddenProcessSync,
5258
};

0 commit comments

Comments
 (0)