Skip to content

LIcon encapsulation breaks $refs #385

Open
@ij1

Description

@ij1

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugconfirmedIssue is accepted as either a bug or a valid enhancementhelp wanted

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions