Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(55)

Side by Side Diff: pkg/template_binding/lib/src/binding_delegate.dart

Issue 335943003: merge to trunk all changes from 36817 until 37378 under the packages: polymer, (Closed) Base URL: http://dart.googlecode.com/svn/trunk/dart/
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « pkg/template_binding/CHANGELOG.md ('k') | pkg/template_binding/lib/src/element.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 library template_binding.src.binding_delegate; 5 part of template_binding;
6
7 import 'dart:html';
8 import 'package:template_binding/template_binding.dart' show TemplateInstance;
9 6
10 /** 7 /**
11 * Template Bindings native features enables a wide-range of use cases, 8 * Template Bindings native features enables a wide-range of use cases,
12 * but (by design) don't attempt to implement a wide array of specialized 9 * but (by design) don't attempt to implement a wide array of specialized
13 * behaviors. 10 * behaviors.
14 * 11 *
15 * Enabling these features is a matter of implementing and registering a 12 * Enabling these features is a matter of implementing and registering a
16 * BindingDelegate. A binding delegate is an object which contains one or more 13 * BindingDelegate. A binding delegate is an object which contains one or more
17 * delegation functions which implement specialized behavior. This object is 14 * delegation functions which implement specialized behavior. This object is
18 * registered via [TemplateBindExtension.bindingDelegate]: 15 * registered via [TemplateBindExtension.bindingDelegate]:
(...skipping 13 matching lines...) Expand all
32 * templateBind(query('template')) 29 * templateBind(query('template'))
33 * ..bindingDelegate = new MySyntax() 30 * ..bindingDelegate = new MySyntax()
34 * ..model = new MyModel(); 31 * ..model = new MyModel();
35 * 32 *
36 * 33 *
37 * See 34 * See
38 * <http://www.polymer-project.org/platform/template.html#binding-delegate-api> 35 * <http://www.polymer-project.org/platform/template.html#binding-delegate-api>
39 * for more information about the binding delegate. 36 * for more information about the binding delegate.
40 */ 37 */
41 // TODO(jmesserly): need better api docs here. The link above seems out of date. 38 // TODO(jmesserly): need better api docs here. The link above seems out of date.
42 abstract class BindingDelegate { 39 class BindingDelegate {
43 /** 40 /**
44 * Prepares a binding. This is called immediately after parsing a mustache 41 * Prepares a binding. This is called immediately after parsing a mustache
45 * token with `{{ path }}` in the context of the [node] and the property named 42 * token with `{{ path }}` in the context of the [node] and the property named
46 * [name]. This should return a function that will be passed the actual 43 * [name]. This should return a function that will be passed the actual
47 * node and model, and either returns null or an object with a `value` 44 * node and model, and either returns null or an object with a `value`
48 * property. This allows the syntax to reinterpret the model for each binding. 45 * property. This allows the syntax to reinterpret the model for each binding.
49 */ 46 */
50 PrepareBindingFunction prepareBinding(String path, String name, Node node) 47 PrepareBindingFunction prepareBinding(String path, String name, Node node)
51 => null; 48 => null;
52 49
53 /** 50 /**
54 * Returns a function that can optionally replace the model that will be 51 * Returns a function that can optionally replace the model that will be
55 * passed to [TemplateBindExtension.createInstance]. This can be used to 52 * passed to [TemplateBindExtension.createInstance]. This can be used to
56 * implement syntax such as `<template repeat="{{ item in items }}">` by 53 * implement syntax such as `<template repeat="{{ item in items }}">` by
57 * ensuring that the returned model has the "item" name available. 54 * ensuring that the returned model has the "item" name available.
58 */ 55 */
59 PrepareInstanceModelFunction prepareInstanceModel(Element template) => null; 56 PrepareInstanceModelFunction prepareInstanceModel(Element template) => null;
60 57
61 /** 58 /**
62 * Returns a function that will be called whenever the position of an item 59 * Returns a function that will be called whenever the position of an item
63 * inside this template changes. 60 * inside this template changes.
64 */ 61 */
65 PrepareInstancePositionChangedFunction prepareInstancePositionChanged( 62 PrepareInstancePositionChangedFunction prepareInstancePositionChanged(
66 Element template) => null; 63 Element template) => null;
64
65 Expando<_InstanceBindingMap> _bindingMaps;
66
67 // TODO(jmesserly): if we have use this everywhere, we can avoid many
68 // delegate != null checks throughout the code, simplifying things.
69 // For now we just use it for _bindingMaps.
70 static final _DEFAULT = new BindingDelegate();
67 } 71 }
68 72
69 typedef PrepareBindingFunction(model, Node node, bool oneTime); 73 typedef PrepareBindingFunction(model, Node node, bool oneTime);
70 74
71 typedef PrepareInstanceModelFunction(model); 75 typedef PrepareInstanceModelFunction(model);
72 76
73 typedef PrepareInstancePositionChangedFunction(TemplateInstance instance, 77 typedef PrepareInstancePositionChangedFunction(TemplateInstance instance,
74 int index); 78 int index);
OLDNEW
« no previous file with comments | « pkg/template_binding/CHANGELOG.md ('k') | pkg/template_binding/lib/src/element.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698