mcguffin / acf-openstreetmap-field

WordPress ACF Field for OpenStreetMap
https://wordpress.org/plugins/acf-openstreetmap-field/
GNU General Public License v3.0
107 stars 22 forks source link

Check that dispatchEvent exists and is a function before calling it #101

Closed krisre-sigmabold closed 1 year ago

krisre-sigmabold commented 1 year ago

In the context of ACF blocks, rendered content being updated triggers the "append" action, but with a React component as the argument. React components don't have dispatchEvent (they're not DOM elements), so this function call errors and causes the block to fail to render. This change simply checks whether dispatchEvent exists before calling it.

If the argument to the "append" action is indeed an error in ACF, then if/when it gets fixed, this event will be properly dispatched again. Until then, it will simply do nothing when it would otherwise fail, which is at least an incremental improvement.

Fixes #100