| 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; |
| 11 | 11 |
| 12 import 'dart:async'; | 12 import 'dart:async'; |
| 13 import 'dart:collection'; | 13 import 'dart:collection'; |
| 14 import 'dart:html'; | 14 import 'dart:html'; |
| 15 import 'dart:math' as math; | 15 import 'dart:math' as math; |
| 16 import 'package:observe/observe.dart'; | 16 import 'package:observe/observe.dart'; |
| 17 | 17 |
| 18 // TODO(jmesserly): get this from somewhere else. See http://dartbug.com/4161. | 18 // TODO(jmesserly): get this from somewhere else. See http://dartbug.com/4161. |
| 19 import 'package:serialization/src/serialization_helpers.dart' show IdentityMap; | 19 import 'package:serialization/src/serialization_helpers.dart' show IdentityMap; |
| 20 | 20 |
| 21 part 'src/bindings.dart'; | 21 part 'src/bindings.dart'; |
| 22 part 'src/element.dart'; | 22 part 'src/element.dart'; |
| 23 part 'src/input_element.dart'; | 23 part 'src/input_element.dart'; |
| 24 part 'src/node.dart'; | 24 part 'src/node.dart'; |
| 25 part 'src/select_element.dart'; |
| 25 part 'src/template.dart'; | 26 part 'src/template.dart'; |
| 26 part 'src/text.dart'; | 27 part 'src/text.dart'; |
| 27 | 28 |
| 28 /** Initialize the Model-Driven Views polyfill. */ | 29 /** Initialize the Model-Driven Views polyfill. */ |
| 29 void initialize() { | 30 void initialize() { |
| 30 TemplateElement.mdvPackage = _mdv; | 31 TemplateElement.mdvPackage = _mdv; |
| 31 } | 32 } |
| 32 | 33 |
| 33 StreamController<DocumentFragment> _instanceCreated; | 34 StreamController<DocumentFragment> _instanceCreated; |
| 34 | 35 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 // if we decide to integrate MDV into the DOM later, and means less code needs | 77 // if we decide to integrate MDV into the DOM later, and means less code needs |
| 77 // to worry about expandos. | 78 // to worry about expandos. |
| 78 final Expando _mdvExpando = new Expando('mdv'); | 79 final Expando _mdvExpando = new Expando('mdv'); |
| 79 | 80 |
| 80 _mdv(node) { | 81 _mdv(node) { |
| 81 var wrapper = _mdvExpando[node]; | 82 var wrapper = _mdvExpando[node]; |
| 82 if (wrapper != null) return wrapper; | 83 if (wrapper != null) return wrapper; |
| 83 | 84 |
| 84 if (node is InputElement) { | 85 if (node is InputElement) { |
| 85 wrapper = new _InputElementExtension(node); | 86 wrapper = new _InputElementExtension(node); |
| 87 } else if (node is SelectElement) { |
| 88 wrapper = new _SelectElementExtension(node); |
| 86 } else if (node is Element) { | 89 } else if (node is Element) { |
| 87 if (node.isTemplate) { | 90 if (node.isTemplate) { |
| 88 wrapper = new _TemplateExtension(node); | 91 wrapper = new _TemplateExtension(node); |
| 89 } else { | 92 } else { |
| 90 wrapper = new _ElementExtension(node); | 93 wrapper = new _ElementExtension(node); |
| 91 } | 94 } |
| 92 } else if (node is Text) { | 95 } else if (node is Text) { |
| 93 wrapper = new _TextExtension(node); | 96 wrapper = new _TextExtension(node); |
| 94 } else if (node is Node) { | 97 } else if (node is Node) { |
| 95 wrapper = new _NodeExtension(node); | 98 wrapper = new _NodeExtension(node); |
| 96 } else { | 99 } else { |
| 97 // TODO(jmesserly): this happens for things like CompoundBinding. | 100 // TODO(jmesserly): this happens for things like CompoundBinding. |
| 98 wrapper = node; | 101 wrapper = node; |
| 99 } | 102 } |
| 100 | 103 |
| 101 _mdvExpando[node] = wrapper; | 104 _mdvExpando[node] = wrapper; |
| 102 return wrapper; | 105 return wrapper; |
| 103 } | 106 } |
| OLD | NEW |