Index: pkg/dev_compiler/tool/input_sdk/private/ddc_runtime/runtime.dart |
diff --git a/pkg/dev_compiler/tool/input_sdk/private/ddc_runtime/runtime.dart b/pkg/dev_compiler/tool/input_sdk/private/ddc_runtime/runtime.dart |
index 207d7ba89d225c72a6beeb6251d053d224012fe3..75484a6b4400480c69ccbaa07cebbd0b85742cd1 100644 |
--- a/pkg/dev_compiler/tool/input_sdk/private/ddc_runtime/runtime.dart |
+++ b/pkg/dev_compiler/tool/input_sdk/private/ddc_runtime/runtime.dart |
@@ -36,69 +36,78 @@ part 'utils.dart'; |
// TODO(vsm): Move polyfill code to dart:html. |
// Note, native extensions are registered onto types in dart.global. |
// This polyfill needs to run before the corresponding dart:html code is run. |
-@JSExportName('global') |
-final global_ = JS( |
+final polyfill = JS( |
'', |
''' |
- function () { |
- if (typeof NodeList !== "undefined") { |
- // TODO(vsm): Do we still need these? |
- NodeList.prototype.get = function(i) { return this[i]; }; |
- NamedNodeMap.prototype.get = function(i) { return this[i]; }; |
- DOMTokenList.prototype.get = function(i) { return this[i]; }; |
- HTMLCollection.prototype.get = function(i) { return this[i]; }; |
+function (window) { |
+ if (typeof window.NodeList !== "undefined") { |
+ // TODO(vsm): Do we still need these? |
+ window.NodeList.prototype.get = function(i) { return this[i]; }; |
+ window.NamedNodeMap.prototype.get = function(i) { return this[i]; }; |
+ window.DOMTokenList.prototype.get = function(i) { return this[i]; }; |
+ window.HTMLCollection.prototype.get = function(i) { return this[i]; }; |
- // Expose constructors for DOM types dart:html needs to assume are |
- // available on window. |
- if (typeof PannerNode == "undefined") { |
- let audioContext; |
- if (typeof AudioContext == "undefined" && |
- (typeof webkitAudioContext != "undefined")) { |
- audioContext = new webkitAudioContext(); |
- } else { |
- audioContext = new AudioContext(); |
- window.StereoPannerNode = |
- audioContext.createStereoPanner().constructor; |
- } |
- window.PannerNode = audioContext.createPanner().constructor; |
- } |
- if (typeof AudioSourceNode == "undefined") { |
- window.AudioSourceNode = MediaElementAudioSourceNode.__proto__; |
- } |
- if (typeof FontFaceSet == "undefined") { |
- // CSS Font Loading is not supported on Edge. |
- if (typeof document.fonts != "undefined") { |
- window.FontFaceSet = document.fonts.__proto__.constructor; |
- } |
- } |
- if (typeof MemoryInfo == "undefined") { |
- if (typeof window.performance.memory != "undefined") { |
- window.MemoryInfo = window.performance.memory.constructor; |
- } |
+ // Expose constructors for DOM types dart:html needs to assume are |
+ // available on window. |
+ if (typeof window.PannerNode == "undefined") { |
+ let audioContext; |
+ if (typeof window.AudioContext == "undefined" && |
+ (typeof window.webkitAudioContext != "undefined")) { |
+ audioContext = new window.webkitAudioContext(); |
+ } else { |
+ audioContext = new window.AudioContext(); |
+ window.StereoPannerNode = |
+ audioContext.createStereoPanner().constructor; |
} |
- if (typeof Geolocation == "undefined") { |
- navigator.geolocation.constructor; |
- } |
- if (typeof Animation == "undefined") { |
- let d = document.createElement('div'); |
- if (typeof d.animate != "undefined") { |
- window.Animation = d.animate(d).constructor; |
- } |
+ window.PannerNode = audioContext.createPanner().constructor; |
+ } |
+ if (typeof window.AudioSourceNode == "undefined") { |
+ window.AudioSourceNode = MediaElementAudioSourceNode.__proto__; |
+ } |
+ if (typeof window.FontFaceSet == "undefined") { |
+ // CSS Font Loading is not supported on Edge. |
+ if (typeof window.document.fonts != "undefined") { |
+ window.FontFaceSet = window.document.fonts.__proto__.constructor; |
} |
- if (typeof SourceBufferList == "undefined") { |
- window.SourceBufferList = new MediaSource().sourceBuffers.constructor; |
+ } |
+ if (typeof window.MemoryInfo == "undefined") { |
+ if (typeof window.performance.memory != "undefined") { |
+ window.MemoryInfo = window.performance.memory.constructor; |
} |
- if (typeof SpeechRecognition == "undefined") { |
- window.SpeechRecognition = window.webkitSpeechRecognition; |
- window.SpeechRecognitionError = window.webkitSpeechRecognitionError; |
- window.SpeechRecognitionEvent = window.webkitSpeechRecognitionEvent; |
+ } |
+ if (typeof window.Geolocation == "undefined") { |
+ window.Geolocation == window.navigator.geolocation.constructor; |
+ } |
+ if (typeof window.Animation == "undefined") { |
+ let d = window.document.createElement('div'); |
+ if (typeof d.animate != "undefined") { |
+ window.Animation = d.animate(d).constructor; |
} |
} |
+ if (typeof window.SourceBufferList == "undefined") { |
+ window.SourceBufferList = new window.MediaSource().sourceBuffers.constructor; |
Jennifer Messerly
2017/07/14 19:38:08
long line
vsm
2017/07/19 15:59:01
Done.
|
+ } |
+ if (typeof window.SpeechRecognition == "undefined") { |
+ window.SpeechRecognition = window.webkitSpeechRecognition; |
+ window.SpeechRecognitionError = window.webkitSpeechRecognitionError; |
+ window.SpeechRecognitionEvent = window.webkitSpeechRecognitionEvent; |
+ } |
+ } |
+} |
+'''); |
+@JSExportName('global') |
+final global_ = JS( |
+ '', |
+ ''' |
+ function () { |
+ // Find global object. |
var globalState = (typeof window != "undefined") ? window |
: (typeof global != "undefined") ? global |
: (typeof self != "undefined") ? self : {}; |
+ $polyfill(globalState); |
+ |
// These settings must be configured before the application starts so that |
// user code runs with the correct configuration. |
let settings = 'ddcSettings' in globalState ? globalState.ddcSettings : {}; |