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

Unified Diff: pkg/mdv/lib/src/template.dart

Issue 34453003: Rename mdv -> template_binding, remove experiemntal apis from dart:html (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/mdv/lib/src/select_element.dart ('k') | pkg/mdv/lib/src/template_iterator.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/mdv/lib/src/template.dart
diff --git a/pkg/mdv/lib/src/template.dart b/pkg/mdv/lib/src/template.dart
deleted file mode 100644
index d2fb47e22904b3eea55d46121edbae735155e669..0000000000000000000000000000000000000000
--- a/pkg/mdv/lib/src/template.dart
+++ /dev/null
@@ -1,104 +0,0 @@
-// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-part of mdv;
-
-/** Extensions to [Element]s that behave as templates. */
-class _TemplateExtension extends _ElementExtension {
- var _model;
- BindingDelegate _bindingDelegate;
- _TemplateIterator _templateIterator;
- bool _scheduled = false;
-
- _TemplateExtension(Element node) : super(node);
-
- Element get node => super.node;
-
- NodeBinding createBinding(String name, model, String path) {
- switch (name) {
- case 'bind':
- case 'repeat':
- case 'if':
- if (_templateIterator == null) {
- _templateIterator = new _TemplateIterator(node);
- }
- // TODO(jmesserly): why do we do this here and nowhere else?
- if (path == null) path = '';
- return new _TemplateBinding(node, name, model, path);
- default:
- return super.createBinding(name, model, path);
- }
- }
-
- /**
- * Creates an instance of the template.
- */
- DocumentFragment createInstance(model, BindingDelegate delegate) {
- var template = node.ref;
- if (template == null) template = node;
-
- var instance = _createDeepCloneAndDecorateTemplates(
- template.ref.content, delegate);
-
- if (_instanceCreated != null) {
- for (var callback in _instanceCreated) callback(instance);
- }
-
- _addBindings(instance, model, delegate);
- _addTemplateInstanceRecord(instance, model);
- return instance;
- }
-
- /**
- * The data model which is inherited through the tree.
- */
- get model => _model;
-
- void set model(value) {
- _model = value;
- _ensureSetModelScheduled();
- }
-
- /**
- * The binding delegate which is inherited through the tree. It can be used
- * to configure custom syntax for `{{bindings}}` inside this template.
- */
- BindingDelegate get bindingDelegate => _bindingDelegate;
-
- void set bindingDelegate(BindingDelegate value) {
- _bindingDelegate = value;
- _ensureSetModelScheduled();
- }
-
- _ensureSetModelScheduled() {
- if (_scheduled) return;
- _scheduled = true;
- scheduleMicrotask(_setModel);
- }
-
- void _setModel() {
- _scheduled = false;
- _addBindings(node, _model, _bindingDelegate);
- }
-}
-
-class _TemplateBinding extends NodeBinding {
- // TODO(jmesserly): MDV uses TemplateIterator as the node, see:
- // https://github.com/Polymer/mdv/issues/127
- _TemplateBinding(node, name, model, path)
- : super(node, name, model, path) {
- _mdv(node)._templateIterator.inputs.bind(property, model, path);
- }
-
- // These are no-ops because we don't use the underlying PathObserver.
- void _observePath() {}
- void boundValueChanged(newValue) {}
-
- void close() {
- if (closed) return;
- var templateIterator = _mdv(node)._templateIterator;
- if (templateIterator != null) templateIterator.inputs.unbind(property);
- super.close();
- }
-}
« no previous file with comments | « pkg/mdv/lib/src/select_element.dart ('k') | pkg/mdv/lib/src/template_iterator.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698