The simplest way to do this might be to call recalcStyle() on the root of the subtree. An alternative would be just to rely on the layout timer.
This is a substantial change, but since we're rewriting the tree builder anyway, maybe this is the right time for such a change.
Here are two cases that would definitely get faster if elements attached lazily instead of individually:
1. An element is added to the page but, before it displays, a script removes it from the page. (More common than you might think.)
2. An element is added to the page but, before it displays, another element is added, or a new stylesheet is loaded, changing the first element's layout or rendering.
In both of these cases, the eager attach done by the parser is just thrown away.
I'd also expect improved cache effects from building the render tree in one go.
Concerns about this approach:
2. attach() has side effects for plugins. Plugins trigger their initialization off of attach(). One solution is to attach plugins before executing any scripts. Another solution is to treat plugin access from script just like any other rendering-dependent access. Another solution is to trigger plugin initialization based on DOM insertion instead of attach().
This doesn't block the master bug because it's not required in this phase. I'd still like to do this, however.