| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 part of $LIBRARYNAME; | 5 part of $LIBRARYNAME; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * Lazy implementation of the child nodes of an element that does not request | 8 * Lazy implementation of the child nodes of an element that does not request |
| 9 * the actual child nodes of an element until strictly necessary greatly | 9 * the actual child nodes of an element until strictly necessary greatly |
| 10 * improving performance for the typical cases where it is not required. | 10 * improving performance for the typical cases where it is not required. |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 int get length => _this.$dom_childNodes.length; | 172 int get length => _this.$dom_childNodes.length; |
| 173 | 173 |
| 174 void set length(int value) { | 174 void set length(int value) { |
| 175 throw new UnsupportedError( | 175 throw new UnsupportedError( |
| 176 "Cannot set length on immutable List."); | 176 "Cannot set length on immutable List."); |
| 177 } | 177 } |
| 178 | 178 |
| 179 Node operator[](int index) => _this.$dom_childNodes[index]; | 179 Node operator[](int index) => _this.$dom_childNodes[index]; |
| 180 } | 180 } |
| 181 | 181 |
| 182 /** |
| 183 * The MDV package, if available. |
| 184 * |
| 185 * This can be used to initialize MDV support via: |
| 186 * |
| 187 * import 'dart:html'; |
| 188 * import 'package:mdv/mdv.dart' as mdv; |
| 189 * main() { |
| 190 * mdv.initialize(); |
| 191 * } |
| 192 */ |
| 193 Function mdvPackage = (node) { |
| 194 throw new UnsupportedError("The MDV package is not available. " |
| 195 "You can enable it with `import 'package:mdv/mdv.dart' as mdv;` and " |
| 196 "`mdv.initialize()`"); |
| 197 }; |
| 198 |
| 199 /** Information about the instantiated template. */ |
| 200 class TemplateInstance { |
| 201 // TODO(rafaelw): firstNode & lastNode should be read-synchronous |
| 202 // in cases where script has modified the template instance boundary. |
| 203 |
| 204 /** The first node of this template instantiation. */ |
| 205 final Node firstNode; |
| 206 |
| 207 /** |
| 208 * The last node of this template instantiation. |
| 209 * This could be identical to [firstNode] if the template only expanded to a |
| 210 * single node. |
| 211 */ |
| 212 final Node lastNode; |
| 213 |
| 214 /** The model used to instantiate the template. */ |
| 215 final model; |
| 216 |
| 217 TemplateInstance(this.firstNode, this.lastNode, this.model); |
| 218 } |
| 219 |
| 182 $(ANNOTATIONS)class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC { | 220 $(ANNOTATIONS)class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC { |
| 183 List<Node> get nodes { | 221 List<Node> get nodes { |
| 184 return new _ChildNodeListLazy(this); | 222 return new _ChildNodeListLazy(this); |
| 185 } | 223 } |
| 186 | 224 |
| 187 void set nodes(Iterable<Node> value) { | 225 void set nodes(Iterable<Node> value) { |
| 188 // Copy list first since we don't want liveness during iteration. | 226 // Copy list first since we don't want liveness during iteration. |
| 189 // TODO(jacobr): there is a better way to do this. | 227 // TODO(jacobr): there is a better way to do this. |
| 190 List copy = new List.from(value); | 228 List copy = new List.from(value); |
| 191 text = ''; | 229 text = ''; |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 * Print out a String representation of this Node. | 289 * Print out a String representation of this Node. |
| 252 */ | 290 */ |
| 253 String toString() => nodeValue == null ? super.toString() : nodeValue; | 291 String toString() => nodeValue == null ? super.toString() : nodeValue; |
| 254 | 292 |
| 255 /** | 293 /** |
| 256 * Binds the attribute [name] to the [path] of the [model]. | 294 * Binds the attribute [name] to the [path] of the [model]. |
| 257 * Path is a String of accessors such as `foo.bar.baz`. | 295 * Path is a String of accessors such as `foo.bar.baz`. |
| 258 */ | 296 */ |
| 259 @Experimental | 297 @Experimental |
| 260 void bind(String name, model, String path) { | 298 void bind(String name, model, String path) { |
| 261 // TODO(jmesserly): should we throw instead? | 299 mdvPackage(this).bind(name, model, path); |
| 262 window.console.error('Unhandled binding to Node: ' | |
| 263 '$this $name $model $path'); | |
| 264 } | 300 } |
| 265 | 301 |
| 266 /** Unbinds the attribute [name]. */ | 302 /** Unbinds the attribute [name]. */ |
| 267 @Experimental | 303 @Experimental |
| 268 void unbind(String name) {} | 304 void unbind(String name) { |
| 305 mdvPackage(this).unbind(name); |
| 306 } |
| 269 | 307 |
| 270 /** Unbinds all bound attributes. */ | 308 /** Unbinds all bound attributes. */ |
| 271 @Experimental | 309 @Experimental |
| 272 void unbindAll() {} | 310 void unbindAll() { |
| 273 | 311 mdvPackage(this).unbindAll(); |
| 274 TemplateInstance _templateInstance; | 312 } |
| 275 | 313 |
| 276 /** Gets the template instance that instantiated this node, if any. */ | 314 /** Gets the template instance that instantiated this node, if any. */ |
| 277 @Experimental | 315 @Experimental |
| 278 TemplateInstance get templateInstance => | 316 TemplateInstance get templateInstance => mdvPackage(this).templateInstance; |
| 279 _templateInstance != null ? _templateInstance : | |
| 280 (parent != null ? parent.templateInstance : null); | |
| 281 | 317 |
| 282 $!MEMBERS | 318 $!MEMBERS |
| 283 } | 319 } |
| OLD | NEW |