perf: hoist global check (#358)

This commit is contained in:
Nolan Lawson 2023-06-30 08:53:49 -07:00 committed by GitHub
parent b829d4c8ce
commit 60eeb8ef17
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 2 deletions

View File

@ -1,12 +1,15 @@
const isFirefoxContentScript = typeof wrappedJSObject !== 'undefined'
// remove some internal implementation details, i.e. the "tokens" array on the emoji object
// essentially, convert the emoji from the version stored in IDB to the version used in-memory
export function cleanEmoji (emoji) {
if (!emoji) {
return emoji
}
// if inside a Firefox content script, need to clone the emoji object to prevent Firefox from complaining about cross-origin object
// if inside a Firefox content script, need to clone the emoji object to prevent Firefox from complaining about
// cross-origin object. See: https://github.com/nolanlawson/emoji-picker-element/issues/356
/* istanbul ignore if */
if (typeof wrappedJSObject !== 'undefined') {
if (isFirefoxContentScript) {
emoji = structuredClone(emoji)
}
delete emoji.tokens