vue-leaflet/Vue2Leaflet

LIcon encapsulation breaks $refs

Open

#385 aperta il 1 mag 2019

Vedi su GitHub
 (9 commenti) (0 reazioni) (0 assegnatari)JavaScript (380 fork)batch import
bugconfirmedhelp wanted

Metriche repository

Star
 (1942 star)
Metriche merge PR
 (Nessuna PR mergiata in 30 g)

Descrizione

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

Guida contributor