| 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 part of dart._runtime; | 4 part of dart._runtime; |
| 5 | 5 |
| 6 /// This library defines a set of general javascript utilities for us | 6 /// This library defines a set of general javascript utilities for us |
| 7 /// by the Dart runtime. | 7 /// by the Dart runtime. |
| 8 // TODO(ochafik): Rewrite some of these in Dart when possible. | 8 // TODO(ochafik): Rewrite some of these in Dart when possible. |
| 9 | 9 |
| 10 defineProperty(obj, name, desc) => | 10 defineProperty(obj, name, desc) => |
| 11 JS('', 'Object.defineProperty(#, #, #)', obj, name, desc); | 11 JS('', 'Object.defineProperty(#, #, #)', obj, name, desc); |
| 12 | 12 |
| 13 getOwnPropertyDescriptor(obj, name) => | 13 getOwnPropertyDescriptor(obj, name) => |
| 14 JS('', 'Object.getOwnPropertyDescriptor(#, #)', obj, name); | 14 JS('', 'Object.getOwnPropertyDescriptor(#, #)', obj, name); |
| 15 | 15 |
| 16 getOwnPropertyNames(obj) => JS('', 'Object.getOwnPropertyNames(#)', obj); | 16 Iterable getOwnPropertyNames(obj) => |
| 17 JS('', 'Object.getOwnPropertyNames(#)', obj); |
| 17 | 18 |
| 18 getOwnPropertySymbols(obj) => JS('', 'Object.getOwnPropertySymbols(#)', obj); | 19 Iterable getOwnPropertySymbols(obj) => |
| 20 JS('', 'Object.getOwnPropertySymbols(#)', obj); |
| 19 | 21 |
| 20 final hasOwnProperty = JS('', 'Object.prototype.hasOwnProperty'); | 22 final hasOwnProperty = JS('', 'Object.prototype.hasOwnProperty'); |
| 21 | 23 |
| 22 // TODO(ochafik): Add ES6 class syntax support to JS intrinsics to avoid this. | 24 // TODO(ochafik): Add ES6 class syntax support to JS intrinsics to avoid this. |
| 23 final StrongModeError = JS('', '''(function() { | 25 final StrongModeError = JS('', '''(function() { |
| 24 function StrongModeError(message) { | 26 function StrongModeError(message) { |
| 25 Error.call(this); | 27 Error.call(this); |
| 26 this.message = message; | 28 this.message = message; |
| 27 }; | 29 }; |
| 28 Object.setPrototypeOf(StrongModeError.prototype, Error.prototype); | 30 Object.setPrototypeOf(StrongModeError.prototype, Error.prototype); |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 } | 118 } |
| 117 | 119 |
| 118 @JSExportName('export') | 120 @JSExportName('export') |
| 119 exportProperty(to, from, name) => copyProperty(to, from, name); | 121 exportProperty(to, from, name) => copyProperty(to, from, name); |
| 120 | 122 |
| 121 /// Copy properties from source to destination object. | 123 /// Copy properties from source to destination object. |
| 122 /// This operation is commonly called `mixin` in JS. | 124 /// This operation is commonly called `mixin` in JS. |
| 123 copyProperties(to, from) { | 125 copyProperties(to, from) { |
| 124 return copyTheseProperties(to, from, getOwnNamesAndSymbols(from)); | 126 return copyTheseProperties(to, from, getOwnNamesAndSymbols(from)); |
| 125 } | 127 } |
| OLD | NEW |