OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 /** | 5 /** |
6 * This library provides access to the Polymer project's | 6 * This library provides access to the Polymer project's |
7 * [Data Binding](http://www.polymer-project.org/docs/polymer/databinding.html) | 7 * [Data Binding](http://www.polymer-project.org/docs/polymer/databinding.html) |
8 * Find more information at the | 8 * Find more information at the |
9 * [Polymer.dart homepage](https://www.dartlang.org/polymer-dart/). | 9 * [Polymer.dart homepage](https://www.dartlang.org/polymer-dart/). |
10 * | 10 * |
11 * Extends the capabilities of the HTML Template Element by enabling it to | 11 * Extends the capabilities of the HTML Template Element by enabling it to |
12 * create, manage, and remove instances of content bound to data defined in | 12 * create, manage, and remove instances of content bound to data defined in |
13 * Dart. | 13 * Dart. |
14 * | 14 * |
15 * Node.bind() is a new method added to all DOM nodes which instructs them to | 15 * Node.bind() is a new method added to all DOM nodes which instructs them to |
16 * bind the named property to the data provided. These allows applications to | 16 * bind the named property to the data provided. These allows applications to |
17 * create a data model in Dart or JavaScript that DOM reacts to. | 17 * create a data model in Dart or JavaScript that DOM reacts to. |
18 */ | 18 */ |
19 library template_binding; | 19 library template_binding; |
20 | 20 |
21 import 'dart:async'; | 21 import 'dart:async'; |
22 import 'dart:collection'; | 22 import 'dart:collection'; |
23 import 'dart:html'; | 23 import 'dart:html'; |
24 import 'dart:svg' show SvgSvgElement; | 24 import 'dart:svg' show SvgSvgElement; |
25 import 'package:observe/observe.dart'; | 25 import 'package:observe/observe.dart'; |
26 | 26 |
27 import 'src/binding_delegate.dart'; | |
28 import 'src/mustache_tokens.dart'; | 27 import 'src/mustache_tokens.dart'; |
29 | 28 |
30 export 'src/binding_delegate.dart'; | 29 part 'src/binding_delegate.dart'; |
31 | |
32 part 'src/element.dart'; | 30 part 'src/element.dart'; |
33 part 'src/input_bindings.dart'; | 31 part 'src/input_bindings.dart'; |
34 part 'src/input_element.dart'; | 32 part 'src/input_element.dart'; |
35 part 'src/instance_binding_map.dart'; | 33 part 'src/instance_binding_map.dart'; |
36 part 'src/node.dart'; | 34 part 'src/node.dart'; |
37 part 'src/select_element.dart'; | 35 part 'src/select_element.dart'; |
38 part 'src/template.dart'; | 36 part 'src/template.dart'; |
39 part 'src/template_iterator.dart'; | 37 part 'src/template_iterator.dart'; |
40 part 'src/text.dart'; | 38 part 'src/text.dart'; |
41 part 'src/text_area_element.dart'; | 39 part 'src/text_area_element.dart'; |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 * | 146 * |
149 * A node is a template if [tagName] is TEMPLATE, or the node has the | 147 * A node is a template if [tagName] is TEMPLATE, or the node has the |
150 * 'template' attribute and this tag supports attribute form for backwards | 148 * 'template' attribute and this tag supports attribute form for backwards |
151 * compatibility with existing HTML parsers. The nodes that can use attribute | 149 * compatibility with existing HTML parsers. The nodes that can use attribute |
152 * form are table elments (THEAD, TBODY, TFOOT, TH, TR, TD, CAPTION, COLGROUP | 150 * form are table elments (THEAD, TBODY, TFOOT, TH, TR, TD, CAPTION, COLGROUP |
153 * and COL), OPTION, and OPTGROUP. | 151 * and COL), OPTION, and OPTGROUP. |
154 */ | 152 */ |
155 bool isSemanticTemplate(Node n) => n is Element && | 153 bool isSemanticTemplate(Node n) => n is Element && |
156 (_isHtmlTemplate(n) || _isAttributeTemplate(n) || _isSvgTemplate(n)); | 154 (_isHtmlTemplate(n) || _isAttributeTemplate(n) || _isSvgTemplate(n)); |
157 | 155 |
| 156 /** Returns true if this is the staging document for a template. */ |
| 157 bool isTemplateStagingDocument(Document d) => _isStagingDocument[d] == true; |
| 158 |
| 159 |
| 160 /** |
| 161 * True to enable [NodeBindingExtension.bindings]. This can be used by tools |
| 162 * such as UI builders to easily inspect live bindings. Defaults to false for |
| 163 * performance reasons. |
| 164 */ |
| 165 bool enableBindingsReflection = false; |
| 166 |
158 // TODO(jmesserly): const set would be better | 167 // TODO(jmesserly): const set would be better |
159 const _SEMANTIC_TEMPLATE_TAGS = const { | 168 const _SEMANTIC_TEMPLATE_TAGS = const { |
160 'caption': null, | 169 'caption': null, |
161 'col': null, | 170 'col': null, |
162 'colgroup': null, | 171 'colgroup': null, |
163 'option': null, | 172 'option': null, |
164 'optgroup': null, | 173 'optgroup': null, |
165 'tbody': null, | 174 'tbody': null, |
166 'td': null, | 175 'td': null, |
167 'tfoot': null, | 176 'tfoot': null, |
168 'th': null, | 177 'th': null, |
169 'thead': null, | 178 'thead': null, |
170 'tr': null, | 179 'tr': null, |
171 }; | 180 }; |
172 | 181 |
173 | 182 |
174 // TODO(jmesserly): investigate if expandos give us enough performance. | 183 // TODO(jmesserly): investigate if expandos give us enough performance. |
175 | 184 |
176 // The expando for storing our MDV extensions. | 185 // The expando for storing our MDV extensions. |
177 // | 186 // |
178 // In general, we need state associated with the nodes. Rather than having a | 187 // In general, we need state associated with the nodes. Rather than having a |
179 // bunch of individual expandos, we keep one per node. | 188 // bunch of individual expandos, we keep one per node. |
180 // | 189 // |
181 // Aside from the potentially helping performance, it also keeps things simpler | 190 // Aside from the potentially helping performance, it also keeps things simpler |
182 // if we decide to integrate MDV into the DOM later, and means less code needs | 191 // if we decide to integrate MDV into the DOM later, and means less code needs |
183 // to worry about expandos. | 192 // to worry about expandos. |
184 final Expando _expando = new Expando('template_binding'); | 193 final Expando _expando = new Expando('template_binding'); |
OLD | NEW |