refactor(render): ts’ify render api

This commit is contained in:
Tobias Bosch
2015-05-18 11:57:20 -07:00
parent bd8724e652
commit 1beadb8607
56 changed files with 938 additions and 948 deletions
-12
View File
@@ -1,12 +0,0 @@
import {DOM} from 'angular2/src/dom/dom_adapter';
export class Title {
getTitle():string {
return DOM.getTitle();
}
setTitle(newTitle:string) {
DOM.setTitle(newTitle);
}
}
+7
View File
@@ -0,0 +1,7 @@
import {DOM} from 'angular2/src/dom/dom_adapter';
export class Title {
getTitle(): string { return DOM.getTitle(); }
setTitle(newTitle: string) { DOM.setTitle(newTitle); }
}
@@ -1,4 +1,4 @@
import {Injectable} from 'angular2/src/di/annotations_impl';
import {Injectable} from 'angular2/di';
import {isPresent, isBlank, RegExpWrapper, BaseException} from 'angular2/src/facade/lang';
import {DOM} from 'angular2/src/dom/dom_adapter';
@@ -18,15 +18,19 @@ export class UrlResolver {
* ## When the `baseUrl` is null
*
* `url` is resolved in the context of the current document.
* If the document location is 'http://www.foo.com/base' and the `url` is 'path/to/here', the resolved url will be
* If the document location is 'http://www.foo.com/base' and the `url` is 'path/to/here', the
* resolved url will be
* 'http://www.foo.com/base/path/to/here'
*
* ## When the `baseUrl` is not null
*
* - when the `url` is null, the `baseUrl` is returned,
* - due to a limitation in the process used to resolve urls (a HTMLLinkElement), `url` must not start with a `/`,
* - if `url` is relative ('path/to/here', './path/to/here'), the resolved url is a combination of `baseUrl` and `url`,
* - if `url` is absolute (it has a scheme: 'http://', 'https://'), the `url` is returned (ignoring the `baseUrl`)
* - due to a limitation in the process used to resolve urls (a HTMLLinkElement), `url` must not
* start with a `/`,
* - if `url` is relative ('path/to/here', './path/to/here'), the resolved url is a combination of
* `baseUrl` and `url`,
* - if `url` is absolute (it has a scheme: 'http://', 'https://'), the `url` is returned
* (ignoring the `baseUrl`)
*
* @param {string} baseUrl
* @param {string} url
@@ -41,10 +45,12 @@ export class UrlResolver {
if (isBlank(url) || url == '') return baseUrl;
if (url[0] == '/') {
// The `HTMLLinkElement` does not allow resolving this case (the `url` would be interpreted as relative):
// The `HTMLLinkElement` does not allow resolving this case (the `url` would be interpreted as
// relative):
// - `baseUrl` = 'http://www.foo.com/base'
// - `url` = '/absolute/path/to/here'
// - the result would be 'http://www.foo.com/base/absolute/path/to/here' while 'http://www.foo.com/absolute/path/to/here'
// - the result would be 'http://www.foo.com/base/absolute/path/to/here' while
// 'http://www.foo.com/absolute/path/to/here'
// is expected (without the 'base' segment).
throw new BaseException(`Could not resolve the url ${url} from ${baseUrl}`);
}
@@ -1,7 +1,5 @@
import {Promise} from 'angular2/src/facade/async';
export class XHR {
get(url: string): Promise<string> {
return null;
}
get(url: string): Promise<string> { return null; }
}
@@ -1,4 +1,4 @@
import {Injectable} from 'angular2/src/di/annotations_impl';
import {Injectable} from 'angular2/di';
import {Promise, PromiseWrapper} from 'angular2/src/facade/async';
import {XHR} from './xhr';
@@ -19,9 +19,7 @@ export class XHRImpl extends XHR {
}
};
xhr.onerror = function() {
completer.reject(`Failed to load ${url}`);
};
xhr.onerror = function() { completer.reject(`Failed to load ${url}`); };
xhr.send();
return completer.promise;