OLD | NEW |
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 * Generates JS helpers for dart:core. This used to be in a file "core.js". | 6 * Generates JS helpers for dart:core. This used to be in a file "core.js". |
7 * Having them in Dart code means we can easily control which are generated. | 7 * Having them in Dart code means we can easily control which are generated. |
8 */ | 8 */ |
9 // TODO(jmesserly): one idea to make this cleaner: put these as private "native" | 9 // TODO(jmesserly): one idea to make this cleaner: put these as private "native" |
10 // methods somewhere in a library that we import. This would be rather elegant | 10 // methods somewhere in a library that we import. This would be rather elegant |
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
401 // the constructor name even for more specialized objects so | 401 // the constructor name even for more specialized objects so |
402 // we have to fall through to the toString() based implementation | 402 // we have to fall through to the toString() based implementation |
403 // below in that case. | 403 // below in that case. |
404 if (typeof(name) == 'string' && name && name != 'Object') return name; | 404 if (typeof(name) == 'string' && name && name != 'Object') return name; |
405 } | 405 } |
406 var string = Object.prototype.toString.call(obj); | 406 var string = Object.prototype.toString.call(obj); |
407 return string.substring(8, string.length - 1); | 407 return string.substring(8, string.length - 1); |
408 } | 408 } |
409 | 409 |
410 function chrome$typeNameOf() { | 410 function chrome$typeNameOf() { |
411 return this.constructor.name; | 411 var name = this.constructor.name; |
| 412 if (name == 'Window') return 'DOMWindow'; |
| 413 return name; |
412 } | 414 } |
413 | 415 |
414 function firefox$typeNameOf() { | 416 function firefox$typeNameOf() { |
415 var name = constructorNameWithFallback(this); | 417 var name = constructorNameWithFallback(this); |
416 if (name == 'Window') return 'DOMWindow'; | 418 if (name == 'Window') return 'DOMWindow'; |
417 if (name == 'Document') return 'HTMLDocument'; | 419 if (name == 'Document') return 'HTMLDocument'; |
418 if (name == 'XMLDocument') return 'Document'; | 420 if (name == 'XMLDocument') return 'Document'; |
419 return name; | 421 return name; |
420 } | 422 } |
421 | 423 |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
582 bound.$length = Math.max(0, funcLength - (argsLength - 1)); | 584 bound.$length = Math.max(0, funcLength - (argsLength - 1)); |
583 return bound; | 585 return bound; |
584 } else { | 586 } else { |
585 var bound = function() { | 587 var bound = function() { |
586 return func.apply(thisObj, arguments); | 588 return func.apply(thisObj, arguments); |
587 }; | 589 }; |
588 bound.$length = funcLength; | 590 bound.$length = funcLength; |
589 return bound; | 591 return bound; |
590 } | 592 } |
591 };"""; | 593 };"""; |
OLD | NEW |