... You can notice that we cache the individual listeners (onClick, etc.) on the $ctx object, because the listeners never change after the component is mounted. However, it's kind of excessive to cache them all individually, when we can cache the entire on object instead.
This should have some small perf benefit since we aren't re-creating the on object over and over again, and because we are doing one cache lookup instead of multiple.
Consider how components with event listeners are compiled.
Input:
Output:
... You can notice that we cache the individual listeners (
onClick
, etc.) on the$ctx
object, because the listeners never change after the component is mounted. However, it's kind of excessive to cache them all individually, when we can cache the entireon
object instead.This should have some small perf benefit since we aren't re-creating the
on
object over and over again, and because we are doing one cache lookup instead of multiple.