joeattardi / picmo

JavaScript emoji picker. Any app, any framework.
https://picmojs.com
MIT License
1.19k stars 117 forks source link

Avoid localStorage shim #278

Closed dEEpProjects closed 1 year ago

dEEpProjects commented 1 year ago

Hello,

I'm using the 5.8.4 version of your fantastic picker.

I have an issue when using your library in environments where localStorage is not available for security reasons. It seems that you perform detection and shim it in case it's inaccessible. However, this has a global effect, and any other code in the same window is no longer aware of the absence of storage.

Could you perform the detection without globally modifying the window.localStorage object?

Thanks.

joeattardi commented 1 year ago

Thanks for letting me know about this, I didn't think of that actually. I will try to get this fixed this week.

dEEpProjects commented 1 year ago

Hi,

Are there any updates regarding this?

joeattardi commented 1 year ago

Not yet, sorry. Got a lot going on right now.

joeattardi commented 1 year ago

Please give version 5.8.5 a try, this should be resolved now.

dEEpProjects commented 1 year ago

The picker doesn't show anymore in incognito mode.

It throws the following exception:

emojiData.ts:133 Uncaught (in promise) Error: Session storage is required to use CDN emoji data.
    at lt (emojiData.ts:133:11)
    at ie (emojiData.ts:182:12)
    at $i (createPicker.ts:15:10)
    at Module.Ri [as createPicker] (createPicker.ts:45:24)
    at VueComponent.renderPicker (emoji-picker.vue:180:42)
    at VueComponent.activated (emoji-picker.vue:283:36)
    at invokeWithErrorHandling (vue.runtime.esm.js:3017:1)
    at callHook$1 (vue.runtime.esm.js:4031:1)
    at activateChildComponent (vue.runtime.esm.js:4003:1)
    at callActivatedHooks (vue.runtime.esm.js:4171:1)

I think the fix should involve detecting the unavailability of the storage and mocking the storage in some non-global object.

joeattardi commented 1 year ago

Unfortunately that's out of my control. That's from a third party library I use, emojibase. When loading emoji data from the CDN, it requires the use of session storage with no way to override it.

The only way around that is to install the emojibase-data package and supply the data statically as described here.