BorisMoore / jsviews

Interactive data-driven views, MVVM and MVP, built on top of JsRender templates
http://www.jsviews.com/#jsviews
MIT License
856 stars 130 forks source link

Cannot set property '_prv' of undefined #382

Closed Mytia closed 7 years ago

Mytia commented 7 years ago

Hi, get this error when inner data-binding elements removed by top data-binding changes:

image This bug came after 84 version, in 83 it doesn't appear. Fixed it by adding checks before use bindingStore[viewId] and viewOrTag, but maybe it have better solution.

image

BorisMoore commented 7 years ago

Thanks for calling this out, but I would love to be able to reproduce your problem, so I can investigate whether a better solution is needed. Can you provide a small sample which shows the problem? (Maybe create a jsfiddle.) It may be the issue is already fixed in the update I will shortly be publishing...

Thank you...

BorisMoore commented 7 years ago

There are many cases of "inner data-binding elements removed by top data-binding changes" - such as in the sample http://www.jsviews.com/#samples/editable/toplevel-for, but without incurring the error you describe. So your error may be due to somethings else in your code or template which is leading to the problem.

Without an example showing your issue, I can't investigate further... Let me know how you get on producing a repro sample... Thanks!

BorisMoore commented 7 years ago

Deleting a movie in http://www.jsviews.com/#samples/editable/toplevel-for gives exactly the same stack trace as in your screenshot, but with no error.

I have attached the planned update (for commit 86). You could test in your environment if the bug occurs still with this update. (Change the extension back to .js).

If not, then we can close this issue. But if the bug does still occur, then I can try to modify the update with an appropriate fix - but only if I can have a repro sample showing the problem - since in most scenarios there has been no issue. It could be there is a bug in your code. With a repro sample I can try to identify what that bug might be due to...

That said, I am hoping to publish commit 86 very soon, so a quick reply would be great. If not it may have to wait till commit 87 at a later date...

jsviews.js.txt

Mytia commented 7 years ago

Hello, sorry for the long answer, was offline ... I was able to reproduce the bug, although it was not easy, and not came from "top data-binding changes" as I said first. I was thinking so because array was refreshing from top data-binding changes. https://jsfiddle.net/nq4372t8/3/ As far as I understand it occurs in the case of a combination of checking #data ({{if #data}}) and sequential updating of the array, first to another array that contains at least one element from the previous one, but necessarily at another position, and then to an empty array.

Perhaps it can be reproduced with a simpler way...

BorisMoore commented 7 years ago

Excellent. That's just what I needed to investigate. Working on it now...

BorisMoore commented 7 years ago

The test sample was perfect for my needs.

I have a fix ready for the next update. Here it is if you want to try it in your environment:

jsviews.js.txt

Mytia commented 7 years ago

Thanks, It's working.

But, have some problems in tags with new version:

  1. method update, it doesn't exists: onAfterLink: function () { this.update(value); };
  2. property with name "class": {{testTag class="className"/}};
  3. using property with name "tag" inside tag methods: init: function () { this.tag = "value"}.
BorisMoore commented 7 years ago

Thanks for testing and calling out those issues. It's very helpful.

Here is an update which addresses your -2 and -3:

jsviews.js.txt

For your issue -1, yes - that is a breaking change - it is renamed to updateValue() (and there is also an upateValues() method, to be used if there are multiple bindTo parameters). See the attached commit notes that I plan to provide:

-CHANGES.txt

Let me know if you see any other problems. The update is an important one, with a number of improvements, so there could be something else that I have missed...

Mytia commented 7 years ago

Thanks, it seems now all began to work fine, while I can't find something not working:)

BorisMoore commented 7 years ago

If you do find something, let me know :). Here is an update with one small change:

jsviews.js.txt

This may be the version I'll use for the next update...

BorisMoore commented 7 years ago

The issues discussed have been resolved by commit 86. I'll close this issue now. (Please re-open or comment if you find further issues. Thanks!)