Skip to content
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

fix: [#1418] Fix Object.{entries,key,values} on Storage #1423

Merged
merged 2 commits into from
May 6, 2024

Conversation

motss
Copy link
Contributor

@motss motss commented May 1, 2024

Background

This fixes #1418.

L79-84 checks that if a property does not exist in proxy target it return undefined for the configuration of the property and Object.keys(window.sessionStorage, '<existent_property_key>') returns { configurable: true, /** truncated for brevity */ } on the browser (Tested on MS Edge 124).

getOwnPropertyDescriptor(storage: Storage, key: string): PropertyDescriptor {
if (
Storage.prototype.hasOwnProperty(key) ||
storage[PropertySymbol.data][key] === undefined
) {
return;
}
return {
value: storage[PropertySymbol.data][key],
writable: true,
enumerable: true,
configurable: false
};
}
});

Changes

  1. Fix Object.{entries,keys,values}() throwing TypeError on Storage by setting { configurable: true } for all existent property in the Storage
  2. Add tests for above changes

Signed-off-by: Rong Sen Ng (motss) <wes.ngrongsen@gmail.com>
@motss motss marked this pull request as ready for review May 1, 2024 12:57
@motss motss requested a review from capricorn86 as a code owner May 1, 2024 12:57
Copy link
Owner

@capricorn86 capricorn86 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your contribution @motss! ⭐

@capricorn86 capricorn86 merged commit 8ceadb3 into capricorn86:master May 6, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[StorageFactory] Unable to use Object.keys|entries|values(sessionStorage) after #1385
2 participants