Revert "feat(core): extract platforms out of core"

This reverts commit 3f4628c0b0.
This commit is contained in:
vsavkin
2015-11-12 13:40:29 -08:00
parent f80321fd26
commit 78280a48af
38 changed files with 468 additions and 451 deletions
@@ -1,14 +0,0 @@
library angular2.src.services.xhr_impl;
import 'dart:async' show Future;
import 'dart:html' show HttpRequest;
import 'package:angular2/core.dart';
import 'package:angular2/compiler.dart' show XHR;
@Injectable()
class XHRImpl extends XHR {
Future<String> get(String url) {
return HttpRequest.request(url).then((HttpRequest req) => req.responseText,
onError: (_) => new Future.error('Failed to load $url'));
}
}
@@ -1,39 +0,0 @@
import {Promise, PromiseWrapper, PromiseCompleter} from 'angular2/src/facade/promise';
import {isPresent} from 'angular2/src/facade/lang';
import {XHR} from 'angular2/src/compiler/xhr';
export class XHRImpl extends XHR {
get(url: string): Promise<string> {
var completer: PromiseCompleter < string >= PromiseWrapper.completer();
var xhr = new XMLHttpRequest();
xhr.open('GET', url, true);
xhr.responseType = 'text';
xhr.onload = function() {
// responseText is the old-school way of retrieving response (supported by IE8 & 9)
// response/responseType properties were introduced in XHR Level2 spec (supported by IE10)
var response = isPresent(xhr.response) ? xhr.response : xhr.responseText;
// normalize IE9 bug (http://bugs.jquery.com/ticket/1450)
var status = xhr.status === 1223 ? 204 : xhr.status;
// fix status code when it is 0 (0 status is undocumented).
// Occurs when accessing file resources or on Android 4.1 stock browser
// while retrieving files from application cache.
if (status === 0) {
status = response ? 200 : 0;
}
if (200 <= status && status <= 300) {
completer.resolve(response);
} else {
completer.reject(`Failed to load ${url}`, null);
}
};
xhr.onerror = function() { completer.reject(`Failed to load ${url}`, null); };
xhr.send();
return completer.promise;
}
}