Skip to content

Commit

Permalink
fix polyfill module (#49)
Browse files Browse the repository at this point in the history
  • Loading branch information
cometkim authored Jul 4, 2024
1 parent a943e9f commit 447b484
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/fifty-rules-shout.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"unicode-segmenter": patch
---

Fix polyfill to do not override existing, and also to be assigned as non-enumerable
12 changes: 9 additions & 3 deletions src/intl-polyfill.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
import { Segmenter } from './intl-adapter.js';

((intl) => {
if (typeof intl !== 'object') {
let key = 'Segmenter';
if (typeof intl !== 'object' || intl.hasOwnProperty(key)) {
return;
}
intl.Segmenter ||= Segmenter;
Object.defineProperty(intl, key, {
value: Segmenter,
enumerable: false,
writable: true,
configurable: true,
});
})(globalThis.Intl);

/* Not a pure module */
/* Not a pure module */

0 comments on commit 447b484

Please sign in to comment.