Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove the use of document.querySelector to a more local search using 'this' #1368

Open
AliyanH opened this issue Feb 25, 2023 · 3 comments · May be fixed by #1382
Open

Remove the use of document.querySelector to a more local search using 'this' #1368

AliyanH opened this issue Feb 25, 2023 · 3 comments · May be fixed by #1382
Labels

Comments

@AliyanH
Copy link

AliyanH commented Feb 25, 2023

Hello, document.querySelector returns the first element in the document matching the specified selector. This can cause an issue when the web page has multiple Leaflet maps in the page (as the first map will always be selected even when called from the second map).

Similarly, document.querySelector does not search inside of a ShadowRoot which can cause an issue when the leaflet map is inside of one, and create an error (which is the case for me).

I believe the use of document.querySelector can be changed to do a more local search for the map, which can always return the right element. For ex, the following code (which is causing an error for me) can be change from this:

document.querySelector('.leaflet-marker-pane').appendChild(el);

To this:
this._map._container.querySelector('.leaflet-marker-pane').appendChild(el);

Please let me know what you think, Thanks.

@AliyanH AliyanH added the bug label Feb 25, 2023
@welcome
Copy link

welcome bot commented Feb 25, 2023

Thanks for opening your first issue here! This space is protected by our Code of Conduct - and we're here to help.
Please follow the issue template to help us help you 👍🎉😄
If you have screenshots or a gif to share demonstrating the issue, that's really helpful! 📸
You can make a gif too!
Do join our Gitter channel for some brainstorming discussions.

@hound77
Copy link

hound77 commented Mar 3, 2023

@AliyanH Can I work on this issue?

@AliyanH
Copy link
Author

AliyanH commented Mar 3, 2023

@AliyanH Can I work on this issue?

Yup, good with me. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants