| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2014 Google Inc. All rights reserved. | 2 * Copyright 2014 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style | 4 * Use of this source code is governed by a BSD-style |
| 5 * license that can be found in the LICENSE file or at | 5 * license that can be found in the LICENSE file or at |
| 6 * https://developers.google.com/open-source/licenses/bsd | 6 * https://developers.google.com/open-source/licenses/bsd |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 part of charted.selection; | 9 part of charted.selection; |
| 10 | 10 |
| 11 /** SelectionScope represents a scope for all the data and DOM operations. */ | 11 /** SelectionScope represents a scope for all the data and DOM operations. */ |
| 12 class SelectionScope { | 12 class SelectionScope { |
| 13 Expando _associations = new Expando(); | 13 Expando _associations = new Expando(); |
| 14 Expando<Map<String, Pair<Function, bool>>> _listeners = new Expando(); | 14 Expando<Map<String, Pair<EventListener, bool>>> _listeners = new Expando(); |
| 15 Element _root; | 15 Element _root; |
| 16 | 16 |
| 17 /** Creates a new selection scope with document as the root. */ | 17 /** Creates a new selection scope with document as the root. */ |
| 18 SelectionScope() { | 18 SelectionScope() { |
| 19 _root = document.documentElement; | 19 _root = document.documentElement; |
| 20 } | 20 } |
| 21 | 21 |
| 22 /** | 22 /** |
| 23 * Creates a new selection scope with the first element matching | 23 * Creates a new selection scope with the first element matching |
| 24 * [selector] as the root. | 24 * [selector] as the root. |
| (...skipping 25 matching lines...) Expand all Loading... |
| 50 | 50 |
| 51 /* | 51 /* |
| 52 * Current event for which a callback is being called. | 52 * Current event for which a callback is being called. |
| 53 */ | 53 */ |
| 54 Event event; | 54 Event event; |
| 55 | 55 |
| 56 /** Returns the stored for the given [element]. */ | 56 /** Returns the stored for the given [element]. */ |
| 57 datum(Object element) => element == null ? null : _associations[element]; | 57 datum(Object element) => element == null ? null : _associations[element]; |
| 58 | 58 |
| 59 /** Associates data to the given [element]. */ | 59 /** Associates data to the given [element]. */ |
| 60 associate(Object element, datum) => | 60 associate(Element element, datum) => |
| 61 datum != null ? _associations[element] = datum : null; | 61 datum != null ? _associations[element] = datum : null; |
| 62 | 62 |
| 63 /** | 63 /** |
| 64 * Creates a new [Selection] containing the first element matching | 64 * Creates a new [Selection] containing the first element matching |
| 65 * [selector]. If no element matches, the resulting selection will | 65 * [selector]. If no element matches, the resulting selection will |
| 66 * have a null element. | 66 * have a null element. |
| 67 */ | 67 */ |
| 68 Selection select(String selector) => | 68 Selection select(String selector) => |
| 69 new _SelectionImpl.single(selector: selector, scope: this); | 69 new _SelectionImpl.single(selector: selector, scope: this); |
| 70 | 70 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 87 * Appends a new element to [root] and creates a selection containing | 87 * Appends a new element to [root] and creates a selection containing |
| 88 * the newly added element. | 88 * the newly added element. |
| 89 */ | 89 */ |
| 90 Selection append(String tag) { | 90 Selection append(String tag) { |
| 91 var element = Namespace.createChildElement(tag, _root); | 91 var element = Namespace.createChildElement(tag, _root); |
| 92 root.children.add(element); | 92 root.children.add(element); |
| 93 | 93 |
| 94 return selectElements([element]); | 94 return selectElements([element]); |
| 95 } | 95 } |
| 96 } | 96 } |
| OLD | NEW |