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

refs in v-memo on looped template tag are missing _ctx in transpiled code #5288

Closed
Fuzzyma opened this issue Jan 19, 2022 · 0 comments · Fixed by #5291
Closed

refs in v-memo on looped template tag are missing _ctx in transpiled code #5288

Fuzzyma opened this issue Jan 19, 2022 · 0 comments · Fixed by #5291
Labels
🐞 bug Something isn't working

Comments

@Fuzzyma
Copy link

Fuzzyma commented Jan 19, 2022

Version

3.2.27

Reproduction link

sfc.vuejs.org/

Steps to reproduce

Putting a v-memo on a template that has a for loop is discouraged by the linter but totally possible (and extremely useful in my case). However, this code:

<template>
  <template v-for="l of list" :key="l" v-memo="[someVal]">
    <div>
      {{ l }}
    </div>
  </template>
</template>

transpiles to this:

function render(_ctx, _cache, $props, $setup, $data, $options) {
  return (_openBlock(true), _createElementBlock(_Fragment, null, _renderList(_ctx.list, (l, __, ___, _cached) => {
    const _memo = ([someVal])
    if (_cached && _cached.key === l && _isMemoSame(_cached, _memo)) return _cached
    const _item = (_openBlock(), _createElementBlock("div", { key: l }, _toDisplayString(l), 1 /* TEXT */))
    _item.memo = _memo
    return _item
  }, _cache, 0), 128 /* KEYED_FRAGMENT */))
}

As you can see, the value in memo is missing the _ctx

What is expected?

A _ctx for all memo values

What is actually happening?

no ctx


Funny enough a workaround for this is to manually put a _ctx in front of the values in the template. However, this only works as long as the internals of the template transpiler stay the same

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞 bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants