I see two problems with your patch:
- it doesn't handle the $invalid.prop case, only $valid.invalid.invalid case
- it calculates the reference full name for every reference, which looks like overkill (we'd like to only calculate it whenever we encounter a null)
There are other considerations about this feature:
- how should tests on references behave? should #if($invalid) or #if($valid.invalid.invalid) also use the event handler and use its result? It's not the case for now.
- would strict mode be impacted? Right now, strict mode and invalid reference events are orthogonal features.
At start, this event handler was thought as a debugging feature, and not meant to include business logic. If you still think it's pertinent, could you elaborate a bit on your use case? Are you sure there isn't any easier way of handling it? For instance, have you considered using a custom uberspector?