emberjs/ember.js — pull request #10066 by mixonic (2014-12-28 21:03:35+00:00)
Title: [BUGFIX beta] WIP AttrNodes managed by renderer, update to new HTMLBars hooks

Paired with https://github.com/tildeio/htmlbars/pull/225 and HTMLBars master (HTMLBars will need a fresh release before this can be updated and merged).

The previous AttrNode construct had large faults.

* Some of what it did (dirty tracking, render timing) is already done by the renderer
* It had no teardown/un-scheduling/un-subscribe
* Some of what is did paralleled the role of morphs
* It required access to the DOM helper for instantiation, but some features (like attribute bindings) don't have access to the dom helper. The only have access to the render tree via childViews.

This PR and the PR in HTMLBars address this by breaking the old attribute system into parts:

* `setProp` is a new function on `DOMHelper`. It sets a property if one is present on an element, and if one is not falls back to setting an attribute.
* `AttrMorph` is a new interface exposing `setContent` and a few other features. It manages escaping content is needed, and encapsulates the element and attribute to be updated in a portable object.
* `AttrNode` is a port of the old class which duck-types an ember metal view. It can be added to `childViews` on a parent view and be managed by the renderer.

This improves the current system greatly while only changing the API to have improved consistency (HTMLBars attrs will use the same code as bound attrs now, for instance). I would prefer to land it in beta.

TODO:

* [ ] Review & merge https://github.com/tildeio/htmlbars/pull/225, release HTMLBars
* [ ] Update this PR to point at the latest HTMLBars. (also emberjs-build?)
* [ ] Update the htmlbars attr syntax feature to run on attr nodes
* [ ] Review of hook usage by @mmun - I flew blind on this one
* [ ] Update attribute bindings and class name bindings (I don't want to block on this though)