question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

#7981 is a breaking change

See original GitHub issue

Version

2.5.18-beta.0

Reproduction link

https://jsfiddle.net/50wL7mdz/806315/

Steps to reproduce

Change src attributes in HTML to try w/ different versions

What is expected?

isChanged computed property to be true after delay

What is actually happening?

it doesn’t get an updated value of isChanged


Let’s consider a bit simplified situation of my real one. Suppose I have a DataWrapper which purpose is to tell whether the held data object was changed or not.

This wrapper has 2 properties: isChanged (read-only, boolean, false by default) and data (read-write, any type); and it is initialized w/ some data.

I think it’s clear and not a problem that isChanged property should only have a getter, but for the sake of reactivity, it’s allowed to have setter be added. Also, in data setter there’s a line

try { this.isChanged = true } catch (e) {/*ignore*/}

for this purpose, i.e. if a setter was defined by some reactivity library (built into Vue in our case), we should invoke it before changing the internal state to let it pass the Vue’s check and propagate the change across dependent values:

if (newVal === value || (newVal !== newVal && value !== value)) {
    return
}

But then, since we hadn’t any setter initially defined for isChanged property, the following check

// #7981: for accessor properties without setter
if (getter && !setter) { return }

, which was added in PR #7981, is failed and the change is not propagated, which is definitely not a desired behavior.

Commenting of this line completely solves the problem.

So I consider this change as a breaking and think it should be reverted to original behavior.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
LinusBorgcommented, Dec 16, 2018

Well, I see it like this: #7981 was introduced to skip unnecessary obervations:

In a usual scenario, an object property that only has a getter and no setter can only be changed by other means unknown to Vue. Vue can only track changes through a setter, which the object in question apparently doesn’t use. So there’s no use in making this object reactive. 99 times out of a 100, we would otherwise observe an object property that, as far as Vue can tell, won’t ever change.

Now, before this PR, we did add this setter, and you are the 1 in a 100 case where the author actively checks for this setter to call it just to accomodate Vue.

But I’m not really willing to call this a breaking change as we never made that implementation detail part of our public API contract. To the contrary, we have warnings like this one in our docs:

The object must be plain: native objects such as browser API objects and prototype properties are ignored. A rule of thumb is that data should just be data - it is not recommended to observe objects with their own stateful behavior. source

You are of coure free to work around these limitations like you did, but it’s not our responsibility to think of each possible interaction with stateful objects in reactive data (that we explicitly warn against) when doing internal changes.

2reactions
LinusBorgcommented, Dec 18, 2018

Thanks for understanding. I hope you find a good way to solve your issue

Read more comments on GitHub >

github_iconTop Results From Across the Web

vuejs/vue #7981 is a breaking change - JSFiddle - Code Playground
The fiddle listings (Public, Private, Titled, etc) will now display latest versions instead of the ones saved as Base versions - this was...
Read more >
breaking change - Wiktionary
breaking change (plural breaking changes). (computing) A change in one part of a software system that potentially causes other components to fail; ...
Read more >
Zarah Sultana MP on Twitter: "With record-breaking 40ºC+ ...
With record-breaking 40ºC+ temperatures now recorded, ... This is a capitalist crisis and only system change can avert climate catastrophe.
Read more >
About - Break Free Health & Wellness, LLC
Call Us! 1-608-752-7981 ... Breaking Free – Helping Others! ... there are three things needed to make any change, mental, emotional, or physical:...
Read more >
Benefits Vendor Phone Number Website
ADP Services. 1-800-770-7981 www.benedirect.adp.com. Self-Service Portal. Shared Services Center. 1-855-214-2644 www.ssc.usg.edu. 403(b), 457, ORP. Fidelity.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found