ractivejs / ractive

Next-generation DOM manipulation
http://ractive.js.org
MIT License
5.94k stars 396 forks source link

v0.9 -> v0.10: adding warning in unscoped methods #3229

Open dagnelies opened 6 years ago

dagnelies commented 6 years ago

Hi,

I noticed that a recent update from https://cdn.jsdelivr.net/npm/ractive (I assume it's "latest" and gone from 0.9 to 0.10) changed how event methods are handled.

Following snippet:

<button on-click="doSomething(this)"></button>

doesn't work anymore and just throws a cryptic exception. Instead it should apparently now be replaced with the more unambiguous:

<button on-click="@this.doSomething(this)"></button>

Due to the widespread usage of calls like on-click="set('my.key.path', 'foo')", I think placing a warning if such methods don't start with a @... would be very helpful. Otherwise, people have no clue what's going on when updating.

fskreuz commented 6 years ago

That's due to resolveInstanceMembers now defaulting to false. See migration notes. TL;DR: All instance members will, by default, explicitly need to be accessed via @this/@.

dagnelies commented 6 years ago

I figured it out the way. I'd be nice to avoid this hassle using a warning for the others. Same for computations still using $.

I'd be like a pre-flight check, just to indicate where people use deprecated stuff.