Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master

More rigorous approach to stream stability

This commit takes a more structured, less ad hoc approach to stream
stability. In particular, the `bindSelf` hook is responsible for
creating a stable set of stream “roots” at first render. On subsequent
renders, those streams are simply updated in place, and if there are
derived “child” streams from those root streams, they will mark their
associated render nodes as dirty.

This ensures that the idempotent in-place rendering strategy can do very
little work, and also remain 100% compatible with mutation observer

Still to do: make sure that lifecycle hooks run asynchronously, after
all rendering has completed.

This commit also introduces the concept of a “Shadow Root”, which is a
general primitive that describes how components and views in Ember
create a hierarchy of *render nodes* with a different scope hierarchy.

Each time a component’s layout is rendered for the first time, a new
“Shadow Root” is also created, which is responsible for linking the
layout into the dynamic node hierarchy, while giving the layout a
totally new scope.

When the layout `{{yield}}`s, the Shadow Root works with HTMLBars to
restore the parent scope.

The responsibility of `ShadowRoot` is primarily to encapsulate the
bookkeeping necessary to properly do an in-place re-render on subsequent
renders. Because HTMLBars already encapsulates the concept of `yield`ing
from a layout, this object is quite small.

Interestingly, because ShadowRoot is exactly the same boundary as the
Web Component’s Shadow DOM, it is also a good location to create a
DOM Shadow Root and render into that. We will likely explore this if
Shadow DOM lands in more browsers.

At the moment, Ember uses the block helper functionality from HTMLBars
to render new top-level scopes. This results in `bindSelf` being called
with the information passed from Ember. Because `bindSelf` is called
both with a user’s `self`, and through Ember internals, we have created
a few symbols that Ember can use to communicate with `bindSelf`.
However, we realize that this is not the optimal solution, and plan for
HTMLBars to expose an internal version of the `block` hook that we can
use to pass a scope through the machinery, rather than a `self` that
contains scoping information through internal symbols.

As we continue to progress, we plan to better document the various
abstraction boundaries, such as ShadowRoot.
latest commit b492d0d680
Tom Dale and Yehuda Katz authored tilde-engineering committed
Something went wrong with that request. Please try again.