mirror of
https://github.com/facebook/docusaurus.git
synced 2025-07-30 06:50:36 +02:00
fix(theme-common): localStorage utils dispatch too many storage events leading to infinite loop (#8619)
This commit is contained in:
parent
140f0b1d4c
commit
5b05c0e73e
1 changed files with 7 additions and 0 deletions
|
@ -31,6 +31,13 @@ function dispatchChangeEvent({
|
|||
newValue: string | null;
|
||||
storage: Storage;
|
||||
}) {
|
||||
// If we set multiple times the same storage value, events should not be fired
|
||||
// The native events behave this way, so our manual event dispatch should
|
||||
// rather behave exactly the same. Not doing so might create infinite loops.
|
||||
// See https://github.com/facebook/docusaurus/issues/8594
|
||||
if (oldValue === newValue) {
|
||||
return;
|
||||
}
|
||||
const event = document.createEvent('StorageEvent');
|
||||
event.initStorageEvent(
|
||||
'storage',
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue