Skip to content

v-once on template with only text children inside a v-for does not work #10892

Closed
@xiangyuecn

Description

@xiangyuecn

Version

2.6.10

Reproduction link

https://codepen.io/xiangyuecn/pen/eYmmPNP

Steps to reproduce

  1. Look at the test code running interface. OnceMsg area should have been static, but it is not!
  2. Look at the Test 3 part of the test code. It's exactly the same as the Test 2 part, but their performance is not the same.
  3. Similar to this kind of code, they are the same, but the results are different:
<div>
	<template v-once>[{{ getTime() }}] {{ name }}</template>
	<span v-once>[{{ getTime() }}] {{ name }}</span>
</div>
<div v-for="obj,idx in logs" :key="idx">
	<div>
		<template v-once>[{{ getTime() }}] {{ obj.msg }}</template>
		<span v-once>[{{ getTime() }}] {{ obj.msg }}</span>
	</div>
</div>

Use <template v-once> because I don't want to use more than one span, which will damage the DOM structure.

What is expected?

<template v-once> in v-for should be consistent with <template v-once> not in v-for, OnceMsg area should have been static.

What is actually happening?

<template v-once> in v-for and <template v-once> not in v-for are inconsistent, The leftmost time of OnceMsg area will change with the cycle.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions