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

Side by Side Diff: pkg/mdv/lib/src/bindings.dart

Issue 17917002: Continue updating MDV. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: merged Created 7 years, 5 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 | « no previous file | pkg/mdv/test/element_bindings_test.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 part of mdv; 5 part of mdv;
6 6
7 // This code is a port of Model-Driven-Views: 7 // This code is a port of Model-Driven-Views:
8 // https://github.com/polymer-project/mdv 8 // https://github.com/polymer-project/mdv
9 // The code mostly comes from src/template_element.js 9 // The code mostly comes from src/template_element.js
10 10
(...skipping 14 matching lines...) Expand all
25 void valueChanged(newValue); 25 void valueChanged(newValue);
26 26
27 void updateBinding(e); 27 void updateBinding(e);
28 28
29 void unbind() { 29 void unbind() {
30 binding = null; 30 binding = null;
31 _pathSub.cancel(); 31 _pathSub.cancel();
32 _eventSub.cancel(); 32 _eventSub.cancel();
33 } 33 }
34 34
35 static EventStreamProvider<Event> _checkboxEventType = () {
36 // Attempt to feature-detect which event (change or click) is fired first
37 // for checkboxes.
38 var div = new DivElement();
39 var checkbox = div.append(new InputElement());
40 checkbox.type = 'checkbox';
41 var fired = [];
42 checkbox.onClick.listen((e) {
43 fired.add(Element.clickEvent);
44 });
45 checkbox.onChange.listen((e) {
46 fired.add(Element.changeEvent);
47 });
48 checkbox.dispatchEvent(new MouseEvent('click', view: window));
49 // WebKit/Blink don't fire the change event if the element is outside the
50 // document, so assume 'change' for that case.
51 return fired.length == 1 ? Element.changeEvent : fired.first;
52 }();
35 53
36 static Stream<Event> _getStreamForInputType(InputElement element) { 54 static Stream<Event> _getStreamForInputType(InputElement element) {
37 switch (element.type) { 55 switch (element.type) {
38 case 'checkbox': 56 case 'checkbox':
39 return element.onClick; 57 return _checkboxEventType.forTarget(element);
40 case 'radio': 58 case 'radio':
41 case 'select-multiple': 59 case 'select-multiple':
42 case 'select-one': 60 case 'select-one':
43 return element.onChange; 61 return element.onChange;
44 default: 62 default:
45 return element.onInput; 63 return element.onInput;
46 } 64 }
47 } 65 }
48 } 66 }
49 67
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after
486 nodeExt._templateIterator = null; 504 nodeExt._templateIterator = null;
487 } 505 }
488 } 506 }
489 507
490 _Bindings._nodeOrCustom(node).unbindAll(); 508 _Bindings._nodeOrCustom(node).unbindAll();
491 for (var c = node.firstChild; c != null; c = c.nextNode) { 509 for (var c = node.firstChild; c != null; c = c.nextNode) {
492 _unbindAllRecursively(c); 510 _unbindAllRecursively(c);
493 } 511 }
494 } 512 }
495 } 513 }
OLDNEW
« no previous file with comments | « no previous file | pkg/mdv/test/element_bindings_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698