feat(compiler, ShadowDom): adds TemplateLoader using XHR.

Also adds css shimming for emulated shadow dom and makes the shadowDom
strategy global to the application.
This commit is contained in:
Victor Berchet
2015-01-30 09:43:21 +01:00
committed by Rado Kirov
parent fcbdf02767
commit 746f85a621
48 changed files with 1583 additions and 303 deletions

View File

@ -0,0 +1,7 @@
import {Promise} from 'angular2/src/facade/async';
export class XHR {
get(url: string): Promise<string> {
return null;
}
}

View File

@ -0,0 +1,12 @@
import 'dart:async';
import 'dart:html';
import './xhr.dart' show XHR;
class XHRImpl extends XHR {
Future<String> get(String url) {
return HttpRequest.request(url).then(
(HttpRequest request) => request.responseText,
onError: (Error e) => throw 'Failed to load $url'
);
}
}

View File

@ -0,0 +1,27 @@
import {Promise, PromiseWrapper} from 'angular2/src/facade/async';
import {XHR} from './xhr';
export class XHRImpl extends XHR {
get(url: string): Promise<string> {
var completer = PromiseWrapper.completer();
var xhr = new XMLHttpRequest();
xhr.open('GET', url, true);
xhr.responseType = 'text';
xhr.onload = function() {
var status = xhr.status;
if (200 <= status && status <= 300) {
completer.complete(xhr.responseText);
} else {
completer.reject(`Failed to load ${url}`);
}
};
xhr.onerror = function() {
completer.reject(`Failed to load ${url}`);
};
xhr.send();
return completer.promise;
}
}