Skip to content
Discussion options

You must be logged in to vote

Yes, this is the Vue reactivity caveat you linked, rather than super() itself. Vue checks the object's type before creating a proxy. Your ordinary class is an Object, but the subclass is an EventTarget, which isn't one of the supported target types. Vue returns that instance unchanged, including its custom properties.

You can see the difference with your two classes:

const plain = new SimpleTurnCounter()
const withEvents = new EventTurnCounter()

Object.prototype.toString.call(withEvents) // "[object EventTarget]"
Alpine.reactive(plain) === plain           // false: a proxy was created
Alpine.reactive(withEvents) === withEvents // true: still the original object

That explains why x-text s…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@laurentbardin
Comment options

Answer selected by laurentbardin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants