| 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 _js_helper; | 5 part of _js_helper; |
| 6 | 6 |
| 7 | 7 |
| 8 // TODO(ngeoffray): stop using this method once our optimizers can | |
| 9 // change str1.contains(str2) into str1.indexOf(str2) != -1. | |
| 10 bool contains(String userAgent, String name) { | |
| 11 return JS('int', '#.indexOf(#)', userAgent, name) != -1; | |
| 12 } | |
| 13 | |
| 14 int arrayLength(List array) { | |
| 15 return JS('int', '#.length', array); | |
| 16 } | |
| 17 | |
| 18 arrayGet(List array, int index) { | |
| 19 return JS('var', '#[#]', array, index); | |
| 20 } | |
| 21 | |
| 22 void arraySet(List array, int index, var value) { | |
| 23 JS('var', '#[#] = #', array, index, value); | |
| 24 } | |
| 25 | |
| 26 propertyGet(var object, String property) { | |
| 27 return JS('var', '#[#]', object, property); | |
| 28 } | |
| 29 | |
| 30 bool callHasOwnProperty(var function, var object, String property) { | |
| 31 return JS('bool', '#.call(#, #)', function, object, property); | |
| 32 } | |
| 33 | |
| 34 void propertySet(var object, String property, var value) { | |
| 35 JS('var', '#[#] = #', object, property, value); | |
| 36 } | |
| 37 | |
| 38 getPropertyFromPrototype(var object, String name) { | |
| 39 return JS('var', 'Object.getPrototypeOf(#)[#]', object, name); | |
| 40 } | |
| 41 | |
| 42 /** | 8 /** |
| 43 * Sets a JavaScript property on an object. | 9 * Sets a JavaScript property on an object. |
| 44 */ | 10 */ |
| 45 void defineProperty(var obj, String property, var value) { | 11 void defineProperty(var obj, String property, var value) { |
| 46 JS('void', | 12 JS('void', |
| 47 'Object.defineProperty(#, #, ' | 13 'Object.defineProperty(#, #, ' |
| 48 '{value: #, enumerable: false, writable: true, configurable: true})', | 14 '{value: #, enumerable: false, writable: true, configurable: true})', |
| 49 obj, | 15 obj, |
| 50 property, | 16 property, |
| 51 value); | 17 value); |
| 52 } | 18 } |
| OLD | NEW |