| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 /** | 5 /** |
| 6 * Support for interoperating with JavaScript. | 6 * Support for interoperating with JavaScript. |
| 7 * | 7 * |
| 8 * This library provides access to JavaScript objects from Dart, allowing | 8 * This library provides access to JavaScript objects from Dart, allowing |
| 9 * Dart code to get and set properties, and call methods of JavaScript objects | 9 * Dart code to get and set properties, and call methods of JavaScript objects |
| 10 * and invoke JavaScript functions. The library takes care of converting | 10 * and invoke JavaScript functions. The library takes care of converting |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 } | 197 } |
| 198 return _convertToDart(JS('', '#[#]', _jsObject, property)); | 198 return _convertToDart(JS('', '#[#]', _jsObject, property)); |
| 199 } | 199 } |
| 200 | 200 |
| 201 /** | 201 /** |
| 202 * Sets the value associated with [property] on the proxied JavaScript | 202 * Sets the value associated with [property] on the proxied JavaScript |
| 203 * object. | 203 * object. |
| 204 * | 204 * |
| 205 * The type of [property] must be either [String] or [num]. | 205 * The type of [property] must be either [String] or [num]. |
| 206 */ | 206 */ |
| 207 operator []=(Object property, value) { | 207 void operator []=(Object property, value) { |
| 208 if (property is! String && property is! num) { | 208 if (property is! String && property is! num) { |
| 209 throw new ArgumentError("property is not a String or num"); | 209 throw new ArgumentError("property is not a String or num"); |
| 210 } | 210 } |
| 211 JS('', '#[#] = #', _jsObject, property, _convertToJS(value)); | 211 JS('', '#[#] = #', _jsObject, property, _convertToJS(value)); |
| 212 } | 212 } |
| 213 | 213 |
| 214 int get hashCode => 0; | 214 int get hashCode => 0; |
| 215 | 215 |
| 216 bool operator ==(other) => | 216 bool operator ==(other) => |
| 217 other is JsObject && JS('bool', '# === #', _jsObject, other._jsObject); | 217 other is JsObject && JS('bool', '# === #', _jsObject, other._jsObject); |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 360 | 360 |
| 361 E operator [](Object index) { | 361 E operator [](Object index) { |
| 362 // TODO(justinfagnani): fix the semantics for non-ints | 362 // TODO(justinfagnani): fix the semantics for non-ints |
| 363 // dartbug.com/14605 | 363 // dartbug.com/14605 |
| 364 if (index is num && index == index.toInt()) { | 364 if (index is num && index == index.toInt()) { |
| 365 _checkIndex(index); | 365 _checkIndex(index); |
| 366 } | 366 } |
| 367 return super[index] as E; | 367 return super[index] as E; |
| 368 } | 368 } |
| 369 | 369 |
| 370 void operator []=(Object index, E value) { | 370 void operator []=(Object index, value) { |
| 371 // TODO(justinfagnani): fix the semantics for non-ints | 371 // TODO(justinfagnani): fix the semantics for non-ints |
| 372 // dartbug.com/14605 | 372 // dartbug.com/14605 |
| 373 if (index is num && index == index.toInt()) { | 373 if (index is num && index == index.toInt()) { |
| 374 _checkIndex(index); | 374 _checkIndex(index); |
| 375 } | 375 } |
| 376 super[index] = value; | 376 super[index] = value; |
| 377 } | 377 } |
| 378 | 378 |
| 379 int get length { | 379 int get length { |
| 380 // Check the length honours the List contract. | 380 // Check the length honours the List contract. |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 580 ' for (let arg of arguments) {' | 580 ' for (let arg of arguments) {' |
| 581 ' args.push(arg);' | 581 ' args.push(arg);' |
| 582 ' }' | 582 ' }' |
| 583 ' return #(...args);' | 583 ' return #(...args);' |
| 584 '}', | 584 '}', |
| 585 f); | 585 f); |
| 586 _interopCaptureThisExpando[f] = ret; | 586 _interopCaptureThisExpando[f] = ret; |
| 587 } | 587 } |
| 588 return ret; | 588 return ret; |
| 589 } | 589 } |
| OLD | NEW |