Index: dart/pkg/browser/lib/dart.js |
diff --git a/dart/pkg/browser/lib/dart.js b/dart/pkg/browser/lib/dart.js |
index 4dd825d1d14268a8c3db7c966394eba2256fcb31..b1f97b1804b6cf57edc33768bcad8523ddb4a23f 100644 |
--- a/dart/pkg/browser/lib/dart.js |
+++ b/dart/pkg/browser/lib/dart.js |
@@ -26,6 +26,22 @@ if (!navigator.dartEnabled && (navigator.userAgent.indexOf('(Dart)') === -1)) { |
// than one script. |
document.currentScript = script; |
parent.replaceChild(script, scripts[i]); |
+ |
+ // Support for incremental compilation. |
+ script.onload = function (event) { |
+ var script = event.target; |
+ if (self.$dart_unsafe_incremental_support) { |
+ new WebSocket(script.src.replace(/^http/, 'ws')).onmessage = |
+ function (event) { |
+ var patch = String(event.data); |
+ self.$dart_unsafe_incremental_support.patch(patch); |
+ script.dispatchEvent( |
+ new CustomEvent( |
+ "dart_program_updated", |
+ { bubbles: true, detail: { patch: patch } })); |
+ }; |
+ } |
+ }; |
} |
} |
} |