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 | 8 // TODO(ngeoffray): stop using this method once our optimizers can |
9 // change str1.contains(str2) into str1.indexOf(str2) != -1. | 9 // change str1.contains(str2) into str1.indexOf(str2) != -1. |
10 bool contains(String userAgent, String name) { | 10 bool contains(String userAgent, String name) { |
(...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
436 // | 436 // |
437 // This is a temporary place for the JavaScript code. | 437 // This is a temporary place for the JavaScript code. |
438 // | 438 // |
439 // TODO(sra): These code fragments are not minified. They could be generated by | 439 // TODO(sra): These code fragments are not minified. They could be generated by |
440 // the code emitter, or JS_CONST could be improved to parse entire functions and | 440 // the code emitter, or JS_CONST could be improved to parse entire functions and |
441 // take care of the minification. | 441 // take care of the minification. |
442 | 442 |
443 const _baseHooks = const JS_CONST(r''' | 443 const _baseHooks = const JS_CONST(r''' |
444 function() { | 444 function() { |
445 function typeNameInChrome(o) { | 445 function typeNameInChrome(o) { |
446 var name = o.constructor.name; | 446 var constructor = o.constructor; |
447 if (constructor) var name = constructor.name; | |
sra1
2014/11/24 18:18:06
While valid and compact JavaScript, this looks a l
floitsch
2014/11/25 12:32:18
Done.
| |
447 if (name) return name; | 448 if (name) return name; |
448 var s = Object.prototype.toString.call(o); | 449 var s = Object.prototype.toString.call(o); |
449 return s.substring(8, s.length - 1); | 450 return s.substring(8, s.length - 1); |
450 } | 451 } |
451 function getUnknownTag(object, tag) { | 452 function getUnknownTag(object, tag) { |
452 // This code really belongs in [getUnknownTagGenericBrowser] but having it | 453 // This code really belongs in [getUnknownTagGenericBrowser] but having it |
453 // here allows [getUnknownTag] to be tested on d8. | 454 // here allows [getUnknownTag] to be tested on d8. |
454 if (/^HTML[A-Z].*Element$/.test(tag)) { | 455 if (/^HTML[A-Z].*Element$/.test(tag)) { |
455 // Check that it is not a simple JavaScript object. | 456 // Check that it is not a simple JavaScript object. |
456 var name = Object.prototype.toString.call(object); | 457 var name = Object.prototype.toString.call(object); |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
639 const _safariHooksTransformer = const JS_CONST(r''' | 640 const _safariHooksTransformer = const JS_CONST(r''' |
640 function(hooks) { return hooks; } | 641 function(hooks) { return hooks; } |
641 '''); | 642 '''); |
642 | 643 |
643 | 644 |
644 const _dartExperimentalFixupGetTagHooksTransformer = const JS_CONST(r''' | 645 const _dartExperimentalFixupGetTagHooksTransformer = const JS_CONST(r''' |
645 function(hooks) { | 646 function(hooks) { |
646 if (typeof dartExperimentalFixupGetTag != "function") return hooks; | 647 if (typeof dartExperimentalFixupGetTag != "function") return hooks; |
647 hooks.getTag = dartExperimentalFixupGetTag(hooks.getTag); | 648 hooks.getTag = dartExperimentalFixupGetTag(hooks.getTag); |
648 }'''); | 649 }'''); |
OLD | NEW |