liquor-tree icon indicating copy to clipboard operation
liquor-tree copied to clipboard

Tree component, integrated with Vuex, doesn't preserve functions in data property

Open become-iron opened this issue 5 years ago • 6 comments

Demo: https://jsfiddle.net/9zLhndy6/20/

Way to reproduce:

  1. Click button to log out tree state -- function is present
  2. Change tree state by click on checkbox
  3. Click button to log out state -- function disappeared

become-iron avatar Jul 24 '19 10:07 become-iron

Hi.

It's correct behaviour. Tree is using JSON.stringify method. That's why functions disappears after change model.

A model is data only. Do not store there anything other than simple data. Use events instead

amsik avatar Jul 25 '19 09:07 amsik

@amsik It took me a while to find out. Please, add the corresponding note in documentation

become-iron avatar Jul 25 '19 17:07 become-iron

Please check MDN: https://developer.mozilla.org/ru/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify

amsik avatar Jul 26 '19 13:07 amsik

Of course, I know how JSON.stringify does work. The issue is it wasn't clear that JSON.stringify is used under hood

become-iron avatar Jul 26 '19 22:07 become-iron

Agree with you (about JSON.stringify is used under hood). But I can't understand why you store function for tree item?

amsik avatar Jul 30 '19 07:07 amsik

I used function in config because it was convenient for my task. And I don't do it now

Could you update docs on this topic?

become-iron avatar Jul 30 '19 16:07 become-iron