Subscribe on changes!

Computed properties function set on sub object properties add double quotes when displayed

avatar
May 5th 2022

Version

3.2.33

Reproduction link

sfc.vuejs.org/

Steps to reproduce

Execute the following code

What is expected?

the string 'test content advanced' should not be display between double quotes

What is actually happening?

Today it display the string between double quotes.


This happens when the computed function, is set on a sub-object property

avatar
May 5th 2022

it's a plain object, so refs are not unwrapped in the template. so you don't print its value, you print the ref object.

When printing ref objects like you do, its value runs through JSON.stringify so that this generates proper JSON:

{{ vm }}

prints:

{ "testComputedAdvanced": "test content advanced" }

The solution to your issue would be to properly print the ref's value:

{{vm.testComputedAdvanced.value}}
avatar
May 5th 2022

Is it possible to compile the code like this?

vm.testComputedAdvanced

compile to

_unref(_unref(vm).testComputedAdvanced)
avatar
May 5th 2022

That would mean you could no longer purposely use a object in the template.l without it being unwrapped.

That would break valid use cases.

So i don't think so, no.