vue-leaflet/Vue2Leaflet

SVG icons with IDs do not work

Open

#514 opened on Jan 23, 2020

View on GitHub
 (5 comments) (0 reactions) (1 assignee)JavaScript (1,942 stars) (380 forks)batch import
bugconfirmedhelp wanted

Description

Description

I'm using SVG icons inside <l-icon>. I have linear <linearGradient> with id="a" and I'm referencing this gradient to fill a circle. When I put the icon outside the map, gradient is nicely filling the circle. When I use same icon inside the map, gradient stops working.

The strange thing is that when I put the same icon inside the map and BEFORE the map, gradient appears in both icons. When I move icon AFTER the map, both icons do not have the gradient.

Looks to me as if this gradient with id="a" was not visible for SVG icon if its first occurence in DOM is inside the map.

I think it's related to this issue: https://github.com/vue-leaflet/Vue2Leaflet/issues/508#issuecomment-570235452.

Live Demo

https://codesandbox.io/s/hungry-bell-y2w1b

Steps to Reproduce

  1. Initially you see both icons have gradient.
  2. Remove <icon /> component from above the map to see that icon inside map does not have gradient.
  3. Put icon below the map to have the same result.

Expected Results

SVG icon inside the map should have linear gradient.

Actual Results

SVG icon only have gradient if there's the same icon before the map in DOM.

Browsers Affected

  • Chrome
  • Firefox
  • Edge
  • Safari 9
  • Safari 8
  • IE 11

Versions

  • Vue: v2.6.11
  • Vue2Leaflet: v2.4.2

Contributor guide