Open
Description
I've noticed that my nonce is not being applied (used Chrome v134.0.6998.89 to test this).
When using the Dynamic Library Import script on https://developers.google.com/maps/documentation/javascript/load-maps-js-api or using the js-api-loader library I noticed that my supplied nonce is not being applied to the generated script.
When checking out the import script and code of the js-api-loader it seems that that nonce is being set by using a .nonce="" syntax. This does not work for me. When adjusting the script and using .setAttribute("nonce", "") it does work tho. What's the reason behind this?
Environment details
- Using the "places" API only; see code example;
- Operating system: Mac OSX 15.3.2
- Chrome v134.0.6998.89
- Library version: v1.16.9
Steps to reproduce
- Create a new project and add the js-api-loader;
- Setup the loader and try to import the "places" library;
- Add a nonce to the Loader constructor params;
- Check if the generated script contain a nonce; It doesn't for me.
Code example
import {Loader} from '@googlemaps/js-api-loader';
const loader = new Loader({
apiKey: "<KEY>",
nonce: "<NONCE>",
version: 'weekly',
libraries: ['places']
});
const {Autocomplete} = await loader.importLibrary('places');