fix: raf should keep same id (#16370)

This commit is contained in:
zombieJ 2019-04-28 23:52:35 +08:00 committed by GitHub
parent 59856a093b
commit fee6b61c19
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 3 deletions

View File

@ -99,6 +99,10 @@ describe('Test utils function', () => {
bamboo = true;
}, 3);
// Do nothing, but insert in the frame
// https://github.com/ant-design/ant-design/issues/16290
delayRaf(() => {}, 3);
// Variable bamboo should be false in frame 2 but true in frame 4
raf(() => {
expect(bamboo).toBe(false);

View File

@ -17,13 +17,13 @@ export default function wrapperRaf(callback: () => void, delayFrames: number = 1
if (restFrames <= 0) {
callback();
delete ids[id];
delete ids[myId];
} else {
ids[id] = raf(internalCallback);
ids[myId] = raf(internalCallback);
}
}
ids[id] = raf(internalCallback);
ids[myId] = raf(internalCallback);
return myId;
}