-
Notifications
You must be signed in to change notification settings - Fork 396
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Array observer callbacks have wrong this
#3343
Comments
Arguably, this is a bug, so it wouldn't be a breaking change. I do have a few bugfixes queued in master, but I've been trying to make as few changes as possible to avoid making uncomfortable diffs here. If it's not bothering anyone, I'm fine with either fixing it now or in the ts branch. |
Ok, I'll apply the patch now otherwise I get type error due the typing of |
marcalexiei
added a commit
to marcalexiei/ractive
that referenced
this issue
Sep 3, 2020
marcalexiei
added a commit
to marcalexiei/ractive
that referenced
this issue
Sep 14, 2020
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Description:
During #3334 I noticed that the
this
set inside array observer callbacks doesn't match the doc.It seems that
this
ofObserverArrayCallback
should be set to Ractive. SeeRactive.d.ts
The problem is inside
ArrayObserver
which invoke callback without changing thethis
:this.callback(this.pending);
To fix the issue I would do something like this:
this.callback.call(this.ractive, this.pending);
however this could result in a breaking change so I would suggest to release change alongside typescript refactor version.
Versions affected:
1.3.x
Platforms affected:
All
Reproduction:
Open this fiddle and check the console:
observe function
– ArrayObserverobserve arrow
– Ractiveobserve as prop
– ArrayObserverThe text was updated successfully, but these errors were encountered: