Created
May 30, 2014 12:59
-
-
Save aam/41bd3746f2018ede956a to your computer and use it in GitHub Desktop.
changes to Dart as of ~2013 to in attempt to make it work on IE8
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Index: sdk/lib/html/dart2js/html_dart2js.dart | |
=================================================================== | |
--- sdk/lib/html/dart2js/html_dart2js.dart (revision 36540) | |
+++ sdk/lib/html/dart2js/html_dart2js.dart (working copy) | |
@@ -35244,7 +35244,7 @@ | |
var options = JS('=Object', '{prototype: #}', proto); | |
if (extendsTagName != null) { | |
- JS('=Object', '#.extends = #', options, extendsTagName); | |
+ JS('=Object', '#.exTends = #', options, extendsTagName); | |
} | |
JS('void', '#.registerElement(#, #)', document, tag, options); | |
Index: sdk/lib/_internal/lib/js_mirrors.dart | |
=================================================================== | |
--- sdk/lib/_internal/lib/js_mirrors.dart (revision 36540) | |
+++ sdk/lib/_internal/lib/js_mirrors.dart (working copy) | |
@@ -2507,7 +2507,7 @@ | |
bool get _hasReturnType => JS('bool', '"ret" in #', _typeData); | |
get _returnType => JS('', '#.ret', _typeData); | |
- bool get _isVoid => JS('bool', '!!#.void', _typeData); | |
+ bool get _isVoid => JS('bool', '!!#.v0id', _typeData); | |
bool get _hasArguments => JS('bool', '"args" in #', _typeData); | |
List get _arguments => JS('JSExtendableArray', '#.args', _typeData); | |
Index: sdk/lib/_internal/lib/js_helper.dart | |
=================================================================== | |
--- sdk/lib/_internal/lib/js_helper.dart (revision 36540) | |
+++ sdk/lib/_internal/lib/js_helper.dart (working copy) | |
@@ -1193,7 +1193,7 @@ | |
// (https://code.google.com/p/v8/issues/detail?id=2519). The default | |
// toString on Error returns the value of 'message' if 'name' is | |
// empty. Setting toString directly doesn't work, see the bug. | |
- JS('void', 'Object.defineProperty(#, "message", { get: # })', | |
+ JS('void', 'try {Object.defineProperty(#, "message", { get: # })}catch(e){}', | |
wrapper, DART_CLOSURE_TO_JS(toStringWrapper)); | |
JS('void', '#.name = ""', wrapper); | |
} else { | |
@@ -2700,7 +2700,7 @@ | |
voidTypeCheck(value) { | |
if (value == null) return value; | |
- throw new TypeErrorImplementation(value, 'void'); | |
+ throw new TypeErrorImplementation(value, 'v0id'); | |
} | |
checkMalformedType(value, message) { | |
@@ -3020,7 +3020,7 @@ | |
class VoidRuntimeType extends RuntimeType { | |
const VoidRuntimeType(); | |
- String toString() => 'void'; | |
+ String toString() => 'v0id'; | |
toRti() => throw 'internal error'; | |
} | |
@@ -3120,7 +3120,7 @@ | |
bool get _hasReturnType => JS('bool', '"ret" in #', _typeData); | |
get _returnType => JS('', '#.ret', _typeData); | |
- bool get _isVoid => JS('bool', '!!#.void', _typeData); | |
+ bool get _isVoid => JS('bool', '!!#.v0id', _typeData); | |
bool get _hasArguments => JS('bool', '"args" in #', _typeData); | |
List get _arguments => JS('JSExtendableArray', '#.args', _typeData); | |
@@ -3180,7 +3180,7 @@ | |
} | |
s += ') -> '; | |
if (_isVoid) { | |
- s += 'void'; | |
+ s += 'v0id'; | |
} else if (_hasReturnType) { | |
s += _convert(_returnType); | |
} else { | |
Index: sdk/lib/_internal/lib/native_helper.dart | |
=================================================================== | |
--- sdk/lib/_internal/lib/native_helper.dart (revision 36540) | |
+++ sdk/lib/_internal/lib/native_helper.dart (working copy) | |
@@ -306,6 +306,12 @@ | |
// property if the function's prototype to a dispatch record. | |
var map = interceptorsByTag; | |
var tags = JS('JSMutableArray', 'Object.getOwnPropertyNames(#)', map); | |
+ // tags = []; | |
+ // for (var propery in map) { | |
+ // if (map.hasOwnProperty(property)) { | |
+ // tags.push(property); | |
+ // } | |
+ // } | |
if (JS('bool', 'typeof window != "undefined"')) { | |
var context = JS('=Object', 'window'); | |
Index: sdk/lib/_internal/compiler/implementation/js_emitter/reflection_data_parser.dart | |
=================================================================== | |
--- sdk/lib/_internal/compiler/implementation/js_emitter/reflection_data_parser.dart (revision 36540) | |
+++ sdk/lib/_internal/compiler/implementation/js_emitter/reflection_data_parser.dart (working copy) | |
@@ -220,7 +220,12 @@ | |
var length = reflectionData.length; | |
for (var i = 0; i < length; i++) { | |
var data = reflectionData[i]; | |
+<<<<<<< .mine | |
+ if (data == null) continue; | |
+''' | |
+======= | |
+>>>>>>> .r36540 | |
// [data] contains these elements: | |
// 0. The library name (not unique). | |
// 1. The library URI (unique). | |
Index: sdk/lib/_internal/compiler/implementation/js_emitter/code_emitter_task.dart | |
=================================================================== | |
--- sdk/lib/_internal/compiler/implementation/js_emitter/code_emitter_task.dart (revision 36540) | |
+++ sdk/lib/_internal/compiler/implementation/js_emitter/code_emitter_task.dart (working copy) | |
@@ -1058,14 +1058,29 @@ | |
} | |
var scripts = document.scripts; | |
+ function onReadyStateChange(event) { | |
+ if (event.srcElement.readyState == "complete") { | |
+ onLoad(event); | |
+ } | |
+ } | |
function onLoad(event) { | |
for (var i = 0; i < scripts.length; ++i) { | |
- scripts[i].removeEventListener("load", onLoad, false); | |
+ var script = scripts[i]; | |
+ if (script.removeEventListener) { | |
+ script.removeEventListener("load", onLoad, false); | |
+ } else { | |
+ script.detachEvent('onreadystatechange', onReadyStateChange); | |
+ } | |
} | |
callback(event.target); | |
} | |
for (var i = 0; i < scripts.length; ++i) { | |
- scripts[i].addEventListener("load", onLoad, false); | |
+ var script = scripts[i]; | |
+ if (script.addEventListener) { | |
+ script.addEventListener("load", onLoad, false); | |
+ } else { | |
+ script.attachEvent('onreadystatechange', onReadyStateChange); | |
+ } | |
} | |
})(function(currentScript) { | |
init.currentScript = currentScript; | |
@@ -1461,6 +1476,55 @@ | |
} | |
mainBuffer.write('])$N'); | |
+ mainBuffer.write( | |
+''' | |
+if (!Object.create) { | |
+ Object.create = (function(){ | |
+ function F(){} | |
+ | |
+ return function(o){ | |
+ if (arguments.length != 1) { | |
+ throw new Error('Object.create implementation only accepts one parameter.'); | |
+ } | |
+ F.prototype = o; | |
+ return new F() | |
+ } | |
+ })() | |
+} | |
+if (typeof Object.getOwnPropertyNames !== "function") { | |
+ Object.getOwnPropertyNames = function (obj) { | |
+ var keys = []; | |
+ | |
+ // Only iterate the keys if we were given an object, and | |
+ // a special check for null, as typeof null == "object" | |
+ if (typeof obj === "object" && obj !== null) { | |
+ // Use a standard for in loop | |
+ for (var x in obj) { | |
+ // A for in will iterate over members on the prototype | |
+ // chain as well, but Object.getOwnPropertyNames returns | |
+ // only those directly on the object, so use hasOwnProperty. | |
+ if (obj.hasOwnProperty(x)) { | |
+ keys.push(x); | |
+ } | |
+ } | |
+ } | |
+ | |
+ return keys; | |
+ } | |
+} | |
+if ( typeof Object.getPrototypeOf !== "function" ) { | |
+ if ( typeof "test".__proto__ === "object" ) { | |
+ Object.getPrototypeOf = function(object){ | |
+ return object.__proto__; | |
+ }; | |
+ } else { | |
+ Object.getPrototypeOf = function(object){ | |
+ // May break if the constructor has been tampered with | |
+ return object.constructor.prototype; | |
+ }; | |
+ } | |
+}'''); | |
+ | |
emitFinishClassesInvocationIfNecessary(mainBuffer); | |
classesCollector = oldClassesCollector; | |
} | |
Index: sdk/lib/_internal/compiler/implementation/js/printer.dart | |
=================================================================== | |
--- sdk/lib/_internal/compiler/implementation/js/printer.dart (revision 36540) | |
+++ sdk/lib/_internal/compiler/implementation/js/printer.dart (working copy) | |
@@ -998,7 +998,7 @@ | |
bool visitFor(For node) => node.body.accept(this); | |
bool visitForIn(ForIn node) => node.body.accept(this); | |
bool visitWhile(While node) => node.body.accept(this); | |
- bool visitDo(Do node) => false; | |
+ bool visitDo(Do node) => true; | |
bool visitContinue(Continue node) => false; | |
bool visitBreak(Break node) => false; | |
bool visitReturn(Return node) => false; | |
Index: sdk/lib/_internal/compiler/implementation/js_backend/namer.dart | |
=================================================================== | |
--- sdk/lib/_internal/compiler/implementation/js_backend/namer.dart (revision 36540) | |
+++ sdk/lib/_internal/compiler/implementation/js_backend/namer.dart (working copy) | |
@@ -886,7 +886,7 @@ | |
String functionTypeTag() => r'func'; | |
- String functionTypeVoidReturnTag() => r'void'; | |
+ String functionTypeVoidReturnTag() => r'v0id'; | |
String functionTypeReturnTypeTag() => r'ret'; | |
Index: tools/testing/dart/browser_controller.dart | |
=================================================================== | |
--- tools/testing/dart/browser_controller.dart (revision 36540) | |
+++ tools/testing/dart/browser_controller.dart (working copy) | |
@@ -143,6 +143,7 @@ | |
Future<bool> startBrowser(String command, | |
List<String> arguments, | |
{Map<String,String> environment}) { | |
+ print("starting $command, $arguments, $environment"); | |
return Process.start(command, arguments, environment: environment) | |
.then((startedProcess) { | |
process = startedProcess; | |
@@ -1388,7 +1389,7 @@ | |
var start = new Date(); | |
function newTaskHandler() { | |
- if (this.readyState == this.DONE) { | |
+ if (this.readyState == 4) { | |
if (this.status == 200) { | |
if (this.responseText == '$waitSignal') { | |
setTimeout(getNextTask, 500); | |
@@ -1455,7 +1456,7 @@ | |
function reportError(msg) { | |
function handleReady() { | |
- if (this.readyState == this.DONE && this.status != 200) { | |
+ if (this.readyState == 4 && this.status != 200) { | |
var error = 'Sending back error did not succeeed: ' + this.status; | |
error = error + '. Failed to send msg: ' + msg; | |
error_div.innerHTML = error; | |
@@ -1488,7 +1489,7 @@ | |
} | |
function handleReady() { | |
- if (this.readyState == this.DONE) { | |
+ if (this.readyState == 4) { | |
if (this.status == 200) { | |
if (!is_double_report) { | |
getNextTask(); | |
@@ -1543,7 +1544,11 @@ | |
} | |
} | |
- window.addEventListener('message', messageHandler, false); | |
+ if (window.addEventListener) { | |
+ window.addEventListener('message', messageHandler, false); | |
+ } else { | |
+ window.attachEvent('onmessage', messageHandler); | |
+ } | |
waitForDone = false; | |
getNextTask(); | |
Index: tools/testing/dart/test_controller.js | |
=================================================================== | |
--- tools/testing/dart/test_controller.js (revision 36540) | |
+++ tools/testing/dart/test_controller.js (working copy) | |
@@ -219,7 +219,11 @@ | |
testRunner.dumpAsText(); | |
testRunner.waitUntilDone(); | |
} | |
-window.addEventListener('message', onReceive, false); | |
+if (window.addEventListener) { | |
+ window.addEventListener('message', onReceive, false); | |
+} else { | |
+ window.attachEvent('onmessage', onReceive); | |
+} | |
function onLoad(e) { | |
// needed for dartium compilation errors. | |
@@ -231,7 +235,11 @@ | |
} | |
} | |
-window.addEventListener('DOMContentLoaded', onLoad, false); | |
+if (window.addEventListener) { | |
+ window.addEventListener('DOMContentLoaded', onLoad, false); | |
+} else { | |
+ window.attachEvent('DOMContentLoaded', onLoad); | |
+} | |
// Note: before renaming this function, note that it is also included in an | |
// inlined error handler in generated HTML files, and manually in tests that |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment