Skip to content

Commit

Permalink
FIO-9607 GoogleAddressProvider: Check for browser API in tryRemoveLib…
Browse files Browse the repository at this point in the history
…rary

  - To my best understanding,  we had a failing test in the OS formio API because:
  - If an address component with a Google provider was rendered via the API, it resulted in an error
  • Loading branch information
blakekrammes committed Jan 14, 2025
1 parent 7cbee3b commit 2bccb41
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/providers/address/GoogleAddressProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ export class GoogleAddressProvider extends AddressProvider {
return;
}

const existingScript = document.querySelector(`script[src^="${GOOGLE_MAPS_JS_URL}"]`);
const existingScript = document?.querySelector?.(`script[src^="${GOOGLE_MAPS_JS_URL}"]`);
if (existingScript && options.params?.key && !existingScript.attributes.src.value.endsWith(options.params.key)) {
const googleMapsScripts = document.querySelectorAll(`script[src^="${GOOGLE_MAPS_BASE_URL}"]`) ?? [];
googleMapsScripts.forEach(script => script.parentNode.removeChild(script));
Expand Down

0 comments on commit 2bccb41

Please sign in to comment.