| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 // TODO(jmesserly): more commentary here. | 5 // TODO(jmesserly): more commentary here. |
| 6 /** | 6 /** |
| 7 * This library provides access to Model-Driven-Views APIs on HTML elements. | 7 * This library provides access to Model-Driven-Views APIs on HTML elements. |
| 8 * More information can be found at: <https://github.com/toolkitchen/mdv>. | 8 * More information can be found at: <https://github.com/toolkitchen/mdv>. |
| 9 */ | 9 */ |
| 10 library mdv; | 10 library mdv; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 | 40 |
| 41 /** | 41 /** |
| 42 * *Warning*: This is an implementation helper for Model-Driven Views and | 42 * *Warning*: This is an implementation helper for Model-Driven Views and |
| 43 * should not be used in your code. | 43 * should not be used in your code. |
| 44 * | 44 * |
| 45 * This event is fired whenever a template is instantiated via | 45 * This event is fired whenever a template is instantiated via |
| 46 * [Element.createInstance]. | 46 * [Element.createInstance]. |
| 47 */ | 47 */ |
| 48 // TODO(rafaelw): This is a hack, and is neccesary for the polyfill | 48 // TODO(rafaelw): This is a hack, and is neccesary for the polyfill |
| 49 // because custom elements are not upgraded during clone() | 49 // because custom elements are not upgraded during clone() |
| 50 // TODO(jmesserly): polymer removed this in: |
| 51 // https://github.com/Polymer/platform/commit/344ffeaae475babb529403f6608588a0fc
73f4e7 |
| 50 Stream<DocumentFragment> get instanceCreated { | 52 Stream<DocumentFragment> get instanceCreated { |
| 51 if (_instanceCreated == null) { | 53 if (_instanceCreated == null) { |
| 52 _instanceCreated = | 54 _instanceCreated = new StreamController<DocumentFragment>(sync: true); |
| 53 new StreamController<DocumentFragment>(sync: true); | |
| 54 } | 55 } |
| 55 return _instanceCreated.stream; | 56 return _instanceCreated.stream; |
| 56 } | 57 } |
| 57 | 58 |
| 58 /** | |
| 59 * Binds all mustaches recursively starting from the [root] node. | |
| 60 * | |
| 61 * Note: this is not an official Model-Driven-Views API; it is intended to | |
| 62 * support binding the [ShadowRoot]'s content to a model. | |
| 63 */ | |
| 64 // TODO(jmesserly): this is needed to avoid two <template> nodes when using | |
| 65 // bindings in a custom element's template. See also: | |
| 66 // https://github.com/polymer-project/polymer/blob/master/src/bindMDV.js#L68 | |
| 67 // Called from: | |
| 68 // https://github.com/polymer-project/polymer/blob/master/src/register.js#L99 | |
| 69 void bindModel(Node root, model, [BindingDelegate delegate]) { | |
| 70 _addBindings(root, model, delegate); | |
| 71 } | |
| 72 | |
| 73 | 59 |
| 74 // TODO(jmesserly): investigate if expandos give us enough performance. | 60 // TODO(jmesserly): investigate if expandos give us enough performance. |
| 75 | 61 |
| 76 // The expando for storing our MDV wrappers. | 62 // The expando for storing our MDV wrappers. |
| 77 // | 63 // |
| 78 // In general, we need state associated with the nodes. Rather than having a | 64 // In general, we need state associated with the nodes. Rather than having a |
| 79 // bunch of individual expandos, we keep one per node. | 65 // bunch of individual expandos, we keep one per node. |
| 80 // | 66 // |
| 81 // Aside from the potentially helping performance, it also keeps things simpler | 67 // Aside from the potentially helping performance, it also keeps things simpler |
| 82 // if we decide to integrate MDV into the DOM later, and means less code needs | 68 // if we decide to integrate MDV into the DOM later, and means less code needs |
| (...skipping 21 matching lines...) Expand all Loading... |
| 104 } else if (node is Node) { | 90 } else if (node is Node) { |
| 105 wrapper = new _NodeExtension(node); | 91 wrapper = new _NodeExtension(node); |
| 106 } else { | 92 } else { |
| 107 // TODO(jmesserly): this happens for things like CompoundBinding. | 93 // TODO(jmesserly): this happens for things like CompoundBinding. |
| 108 wrapper = node; | 94 wrapper = node; |
| 109 } | 95 } |
| 110 | 96 |
| 111 _mdvExpando[node] = wrapper; | 97 _mdvExpando[node] = wrapper; |
| 112 return wrapper; | 98 return wrapper; |
| 113 } | 99 } |
| OLD | NEW |