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

Side by Side Diff: lib/dom/templates/html/impl/impl_MutationObserver.darttemplate

Issue 10696209: MutationObserver (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 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
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC {
6 $!MEMBERS
7 void observe(Node target,
8 [Map options,
9 bool childList,
10 bool attributes,
11 bool characterData,
12 bool subtree,
13 bool attributeOldValue,
14 bool characterDataOldValue,
15 List<String> attributeFilter]) {
16
17 // Parse options into map of known type.
18 var parsedOptions = _createDict();
19
20 if (options != null) {
21 options.forEach((k, v) {
22 if (_boolKeys.containsKey(k)) {
Anton Muhin 2012/07/13 10:50:47 maybe simplify it too: if k != 'attributeFilter' ?
23 _add(parsedOptions, k, true === v);
24 } else if (k == 'attributeFilter') {
25 _add(parsedOptions, k, _fixupList(v));
26 } else {
27 throw new IllegalArgumentException(
28 "Illegal MutationObserver.observe option '$k'");
29 }
30 });
31 }
32
33 // Override options passed in the map with named optional arguments.
34 override(key, value) {
35 if (value != null) _add(parsedOptions, key, value);
36 }
37
38 override('childList', childList);
Anton Muhin 2012/07/13 10:50:47 as another option: override(key, value) { if (v
sra1 2012/07/19 00:34:54 When we get experience with a couple of these 'bag
39 override('attributes', attributes);
40 override('characterData', characterData);
41 override('subtree', subtree);
42 override('attributeOldValue', attributeOldValue);
43 override('characterDataOldValue', characterDataOldValue);
44 if (attributeFilter != null) {
45 override('attributeFilter', _fixupList(attributeFilter));
46 }
47
48 _call(target, parsedOptions);
49 }
50
51 // TODO: Change to a set when const Sets are available.
52 static final _boolKeys =
53 const {'childList': true,
54 'attributes': true,
55 'characterData': true,
56 'subtree': true,
57 'attributeOldValue': true,
58 'characterDataOldValue': true };
59
60 $if DARTIUM
61 static _createDict() => {};
62 static _add(Map m, String key, value) { m[key] = value; }
63 static _lookup(Map m, String key) => m[key];
64 static _fixupList(list) => list;
65
66 _call(Node target, options) {
67 _observe(target, options);
68 }
69 $endif
70
71 $if FROG
72 static _createDict() => JS('var', '{}');
73 static _add(Map m, String key, value) { JS('void', '#[#] = #', m, key, value); }
74 static _lookup(Map m, String key) => JS('var', '#[#]', m, key);
75 static _fixupList(list) => list; // TODO: Ensure is a JavaScript Array.
76
77 // Call native function with no conversions.
78 _call(Node target, options) native 'observe';
79 $endif
80 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698