Adds onAttach event.

Mmk, this is ready for review.

- Works properly for infinitely nested LayoutViews
- Also works on collectionViews
- Documented
- Backwards compatible

This adds `onAttach`. Ref #1856 for more about why this event is important.
Okay but if it is public it needs tests and docs, and we need to make sure that this is the implementation we want for a new public API.