| OLD | NEW |
| 1 @Creates('MutationObserver') | 1 static MutationObserver _create(MutationCallback callback) { |
| 2 @Creates('MutationRecord') | 2 // Dummy statement to mark types as instantiated. |
| 3 static MutationObserver _create(MutationCallback callback) native ''' | 3 JS('MutationObserver|MutationRecord', '0'); |
| 4 var constructor = | |
| 5 window.MutationObserver || window.WebKitMutationObserver || | |
| 6 window.MozMutationObserver; | |
| 7 return new constructor(callback); | |
| 8 '''; | |
| 9 | 4 |
| 10 // TODO(sra): Dart2js inserts a conversion when a Dart function (i.e. an | 5 return JS('MutationObserver', |
| 11 // object with a call method) is passed to a native method. This is so the | 6 'new(window.MutationObserver||window.WebKitMutationObserver||' |
| 12 // native code sees a JavaScript function. | 7 'window.MozMutationObserver)(#)', |
| 13 // | 8 convertDartClosureToJS(callback, 2)); |
| 14 // This does not happen when a function is 'passed' to a JS-form so it is not | 9 } |
| 15 // possible to rewrite the above code to, e.g. (simplified): | |
| 16 // | |
| 17 // static createMutationObserver(MutationCallback callback) => | |
| 18 // JS('var', 'new (window.MutationObserver)(#)', callback); | |
| OLD | NEW |