vue-leaflet/Vue2Leaflet

LIcon encapsulation breaks $refs

Aberta

#385 aberto em 1 de mai. de 2019

 (9 comentários) (0 reação) (0 responsável)JavaScript (380 forks)batch import
bugconfirmedhelp wanted

Métricas do repositório

Stars
 (1.942 estrelas)
Métricas de merge de PR
 (Nenhuma PRs mesclada em 30d)

Description

Description

Steps to Reproduce

  <l-marker
    ref = "marker-container"
    :lat-lng = "[-10, 10]"
  >
    <l-icon
      ref = "icon-container"
      :icon-size = "iconSize"
      :icon-anchor = "iconAnchor"
    >
      <canvas
        ref = "mark-canvas"
        :width = 'iconSize[0]'
        :height = 'iconSize[1]'
        :style = "{
          position: 'absolute',
          left: '0px',
          top: '0px',
        }"
      />
    </l-icon>
  </l-marker>
</template>

Then try to draw into this.$refs['mark-canvas'].

Expected Results

The marker/icon/canvas matches what is drawn to the canvas.

Actual Results

Nothing appears on the canvas. It turns out that there are in fact two canvases, and the visible one is not accessible through $refs as expected (drawing goes to the second, non-visible canvas).

I could access the visible canvas copy with this.$refs['marker-container'].mapObject.getElement().firstChild but is that really the way it is supposed to work (after waiting long enough, in mounted or in $nextTick even that fails)?

Browsers Affected

  • [ x ] Firefox

Probably others too.

Versions

  • Leaflet: v1.3.4
  • Vue: v2.5.18
  • Vue2Leaflet: v2.1.1

Guia do colaborador