OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 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 | 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 $LIBRARYNAME; | 5 part of $LIBRARYNAME; |
6 | 6 |
7 $(ANNOTATIONS)$(NATIVESPEC)$(CLASS_MODIFIERS)class $CLASSNAME$EXTENDS$IMPLEMENTS
{ | 7 $(ANNOTATIONS)$(NATIVESPEC)$(CLASS_MODIFIERS)class $CLASSNAME$EXTENDS$IMPLEMENTS
{ |
8 $!MEMBERS | 8 $!MEMBERS |
9 /** | 9 /** |
10 * Checks to see if the mutation observer API is supported on the current | 10 * Checks to see if the mutation observer API is supported on the current |
11 * platform. | 11 * platform. |
12 */ | 12 */ |
13 static bool get supported { | 13 static bool get supported { |
14 $if DARTIUM | |
15 return true; | |
16 $else | |
17 return JS('bool', | 14 return JS('bool', |
18 '!!(window.MutationObserver || window.WebKitMutationObserver)'); | 15 '!!(window.MutationObserver || window.WebKitMutationObserver)'); |
19 $endif | |
20 } | 16 } |
21 $if DARTIUM | |
22 @DocsEditable() | |
23 static MutationObserver _create(callback) => _blink.BlinkMutationObserver.inst
ance.constructorCallback_1_(callback); | |
24 $endif | |
25 | 17 |
26 /** | 18 /** |
27 * Observes the target for the specified changes. | 19 * Observes the target for the specified changes. |
28 * | 20 * |
29 * Some requirements for the optional parameters: | 21 * Some requirements for the optional parameters: |
30 * | 22 * |
31 * * Either childList, attributes or characterData must be true. | 23 * * Either childList, attributes or characterData must be true. |
32 * * If attributeOldValue is true then attributes must also be true. | 24 * * If attributeOldValue is true then attributes must also be true. |
33 * * If attributeFilter is specified then attributes must be true. | 25 * * If attributeFilter is specified then attributes must be true. |
34 * * If characterDataOldValue is true then characterData must be true. | 26 * * If characterDataOldValue is true then characterData must be true. |
(...skipping 30 matching lines...) Expand all Loading... |
65 | 57 |
66 // TODO: Change to a set when const Sets are available. | 58 // TODO: Change to a set when const Sets are available. |
67 static final _boolKeys = | 59 static final _boolKeys = |
68 const {'childList': true, | 60 const {'childList': true, |
69 'attributes': true, | 61 'attributes': true, |
70 'characterData': true, | 62 'characterData': true, |
71 'subtree': true, | 63 'subtree': true, |
72 'attributeOldValue': true, | 64 'attributeOldValue': true, |
73 'characterDataOldValue': true }; | 65 'characterDataOldValue': true }; |
74 | 66 |
75 $if DARTIUM | |
76 static _createDict() => {}; | |
77 static _add(m, String key, value) { m[key] = value; } | |
78 static _fixupList(list) => list; | |
79 | 67 |
80 void _call(Node target, options) { | |
81 _observe(target, options); | |
82 } | |
83 $endif | |
84 | |
85 $if DART2JS | |
86 static _createDict() => JS('var', '{}'); | 68 static _createDict() => JS('var', '{}'); |
87 static _add(m, String key, value) { JS('void', '#[#] = #', m, key, value); } | 69 static _add(m, String key, value) { JS('void', '#[#] = #', m, key, value); } |
88 static _fixupList(list) => list; // TODO: Ensure is a JavaScript Array. | 70 static _fixupList(list) => list; // TODO: Ensure is a JavaScript Array. |
89 | 71 |
90 // Call native function with no conversions. | 72 // Call native function with no conversions. |
91 @JSName('observe') | 73 @JSName('observe') |
92 void _call(target, options) native; | 74 void _call(target, options) native; |
93 | 75 |
94 factory MutationObserver(MutationCallback callback) { | 76 factory MutationObserver(MutationCallback callback) { |
95 // Dummy statement to mark types as instantiated. | 77 // Dummy statement to mark types as instantiated. |
96 JS('MutationObserver|MutationRecord', '0'); | 78 JS('MutationObserver|MutationRecord', '0'); |
97 | 79 |
98 return JS('MutationObserver', | 80 return JS('MutationObserver', |
99 'new(window.MutationObserver||window.WebKitMutationObserver||' | 81 'new(window.MutationObserver||window.WebKitMutationObserver||' |
100 'window.MozMutationObserver)(#)', | 82 'window.MozMutationObserver)(#)', |
101 convertDartClosureToJS(_wrapBinaryZone(callback), 2)); | 83 convertDartClosureToJS(_wrapBinaryZone(callback), 2)); |
102 } | 84 } |
103 $else | |
104 factory MutationObserver(MutationCallback callback) => | |
105 new MutationObserver._(_wrapBinaryZone(callback)); | |
106 $endif | |
107 } | 85 } |
OLD | NEW |