| OLD | NEW |
| 1 /// The Dart HTML library. | 1 /// The Dart HTML library. |
| 2 /// | 2 /// |
| 3 /// For examples, see | 3 /// For examples, see |
| 4 /// [Dart HTML5 Samples](https://github.com/dart-lang/dart-html5-samples) | 4 /// [Dart HTML5 Samples](https://github.com/dart-lang/dart-html5-samples) |
| 5 /// on Github. | 5 /// on Github. |
| 6 library dart.dom.html; | 6 library dart.dom.html; |
| 7 | 7 |
| 8 import 'dart:async'; | 8 import 'dart:async'; |
| 9 import 'dart:collection'; | 9 import 'dart:collection'; |
| 10 import 'dart:_collection-dev' hide Symbol, deprecated; | 10 import 'dart:_collection-dev' hide Symbol, deprecated; |
| (...skipping 21425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 21436 * ... | 21436 * ... |
| 21437 * query('template').bindingDelegate = new MySyntax(); | 21437 * query('template').bindingDelegate = new MySyntax(); |
| 21438 * query('template').model = new MyModel(); | 21438 * query('template').model = new MyModel(); |
| 21439 * | 21439 * |
| 21440 * See <https://github.com/polymer-project/mdv/blob/master/docs/syntax.md> for | 21440 * See <https://github.com/polymer-project/mdv/blob/master/docs/syntax.md> for |
| 21441 * more information about Custom Syntax. | 21441 * more information about Custom Syntax. |
| 21442 */ | 21442 */ |
| 21443 // TODO(jmesserly): move this type to the MDV package? Two issues: we'd lose | 21443 // TODO(jmesserly): move this type to the MDV package? Two issues: we'd lose |
| 21444 // type annotation on [Element.bindingDelegate], and "mdv" is normally imported | 21444 // type annotation on [Element.bindingDelegate], and "mdv" is normally imported |
| 21445 // with a prefix. | 21445 // with a prefix. |
| 21446 @Experimental() |
| 21446 abstract class BindingDelegate { | 21447 abstract class BindingDelegate { |
| 21447 /** | 21448 /** |
| 21448 * This syntax method allows for a custom interpretation of the contents of | 21449 * This syntax method allows for a custom interpretation of the contents of |
| 21449 * mustaches (`{{` ... `}}`). | 21450 * mustaches (`{{` ... `}}`). |
| 21450 * | 21451 * |
| 21451 * When a template is inserting an instance, it will invoke this method for | 21452 * When a template is inserting an instance, it will invoke this method for |
| 21452 * each mustache which is encountered. The function is invoked with four | 21453 * each mustache which is encountered. The function is invoked with four |
| 21453 * arguments: | 21454 * arguments: |
| 21454 * | 21455 * |
| 21455 * - [model]: The data context for which this instance is being created. | 21456 * - [model]: The data context for which this instance is being created. |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 21548 * already decorated. | 21549 * already decorated. |
| 21549 */ | 21550 */ |
| 21550 @Experimental() | 21551 @Experimental() |
| 21551 static bool decorate(Element template, [Element instanceRef]) { | 21552 static bool decorate(Element template, [Element instanceRef]) { |
| 21552 // == true check because it starts as a null field. | 21553 // == true check because it starts as a null field. |
| 21553 if (template._templateIsDecorated == true) return false; | 21554 if (template._templateIsDecorated == true) return false; |
| 21554 | 21555 |
| 21555 _injectStylesheet(); | 21556 _injectStylesheet(); |
| 21556 | 21557 |
| 21557 var templateElement = template; | 21558 var templateElement = template; |
| 21559 templateElement._templateIsDecorated = true; |
| 21558 var isNative = templateElement is TemplateElement; | 21560 var isNative = templateElement is TemplateElement; |
| 21559 var bootstrapContents = isNative; | 21561 var bootstrapContents = isNative; |
| 21560 var liftContents = !isNative; | 21562 var liftContents = !isNative; |
| 21561 var liftRoot = false; | 21563 var liftRoot = false; |
| 21562 | 21564 |
| 21563 if (!isNative && templateElement._isAttributeTemplate) { | 21565 if (!isNative && templateElement._isAttributeTemplate) { |
| 21564 if (instanceRef != null) { | 21566 if (instanceRef != null) { |
| 21565 // TODO(jmesserly): this is just an assert in MDV. | 21567 // TODO(jmesserly): this is just an assert in MDV. |
| 21566 throw new ArgumentError('instanceRef should not be supplied for ' | 21568 throw new ArgumentError('instanceRef should not be supplied for ' |
| 21567 'attribute templates.'); | 21569 'attribute templates.'); |
| 21568 } | 21570 } |
| 21569 templateElement = _extractTemplateFromAttributeTemplate(template); | 21571 templateElement = _extractTemplateFromAttributeTemplate(template); |
| 21572 templateElement._templateIsDecorated = true; |
| 21570 isNative = templateElement is TemplateElement; | 21573 isNative = templateElement is TemplateElement; |
| 21571 liftRoot = true; | 21574 liftRoot = true; |
| 21572 } | 21575 } |
| 21573 | 21576 |
| 21574 templateElement._templateIsDecorated = true; | |
| 21575 | |
| 21576 if (!isNative) { | 21577 if (!isNative) { |
| 21577 var doc = _getTemplateContentsOwner(templateElement.document); | 21578 var doc = _getTemplateContentsOwner(templateElement.document); |
| 21578 templateElement._templateContent = doc.createDocumentFragment(); | 21579 templateElement._templateContent = doc.createDocumentFragment(); |
| 21579 } | 21580 } |
| 21580 | 21581 |
| 21581 if (instanceRef != null) { | 21582 if (instanceRef != null) { |
| 21582 // template is contained within an instance, its direct content must be | 21583 // template is contained within an instance, its direct content must be |
| 21583 // empty | 21584 // empty |
| 21584 templateElement._templateInstanceRef = instanceRef; | 21585 templateElement._templateInstanceRef = instanceRef; |
| 21585 } else if (liftContents) { | 21586 } else if (liftContents) { |
| (...skipping 7888 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 29474 _position = nextPosition; | 29475 _position = nextPosition; |
| 29475 return true; | 29476 return true; |
| 29476 } | 29477 } |
| 29477 _current = null; | 29478 _current = null; |
| 29478 _position = _array.length; | 29479 _position = _array.length; |
| 29479 return false; | 29480 return false; |
| 29480 } | 29481 } |
| 29481 | 29482 |
| 29482 T get current => _current; | 29483 T get current => _current; |
| 29483 } | 29484 } |
| OLD | NEW |