fix(testing): let DOM adapter dictate XHR implementation for tests

The test injector now uses an XHR implementation based on DOM.getXHR,
which allows the current DOM adapter to dictate which XHR impl should
be used.

To prevent the changes to DOM adapter from introducing undesired new
dependencies into the benchmarks, separate the async facade into
a promise facade which is reexported by facade/async.

See #4539
This commit is contained in:
Julie Ralph
2015-10-14 09:41:15 -07:00
parent 65c737fc95
commit d7ab5d44a5
12 changed files with 136 additions and 116 deletions

View File

@ -5,6 +5,7 @@ import 'package:html/dom.dart';
import 'dom_adapter.dart';
import 'emulated_css.dart';
import '../compiler/xhr.dart';
const _attrToPropMap = const {
'innerHtml': 'innerHTML',
@ -66,6 +67,9 @@ abstract class AbstractHtml5LibAdapter implements DomAdapter {
throw 'not implemented';
}
@override
Type getXHR() => XHR;
Element parse(String templateHtml) => parser.parse(templateHtml).firstChild;
query(selector) {
throw 'not implemented';

View File

@ -1,4 +1,4 @@
import {isBlank} from 'angular2/src/core/facade/lang';
import {isBlank, Type} from 'angular2/src/core/facade/lang';
export var DOM: DomAdapter;
@ -23,6 +23,8 @@ export abstract class DomAdapter {
abstract logGroup(error);
abstract logGroupEnd();
abstract getXHR(): Type;
/**
* Maps attribute names to their corresponding property names for cases
* where attribute name doesn't match property name.

View File

@ -1,6 +1,8 @@
import {ListWrapper, StringMapWrapper} from 'angular2/src/core/facade/collection';
import {isPresent, isFunction, StringWrapper} from 'angular2/src/core/facade/lang';
import {isPresent, isFunction, StringWrapper, Type} from 'angular2/src/core/facade/lang';
import {DomAdapter} from './dom_adapter';
import {XHRImpl} from 'angular2/src/core/compiler/xhr_impl';
/**
* Provides DOM operations in any browser environment.
@ -39,6 +41,8 @@ export abstract class GenericBrowserDomAdapter extends DomAdapter {
this._transitionEnd = null;
}
}
getXHR(): Type { return XHRImpl; }
getDistributedNodes(el: HTMLElement): Node[] { return (<any>el).getDistributedNodes(); }
resolveAndSetHref(el: HTMLAnchorElement, baseUrl: string, href: string) {
el.href = href == null ? baseUrl : baseUrl + '/../' + href;

View File

@ -11,11 +11,13 @@ import {
isPresent,
isBlank,
global,
Type,
setValueOnPath,
DateWrapper
} from 'angular2/src/core/facade/lang';
import {BaseException, WrappedException} from 'angular2/src/core/facade/exceptions';
import {SelectorMatcher, CssSelector} from 'angular2/src/core/compiler/selector';
import {XHR} from 'angular2/src/core/compiler/xhr';
var _attrToPropMap: {[key: string]: string} = {
'class': 'className',
@ -61,6 +63,8 @@ export class Parse5DomAdapter extends DomAdapter {
logGroupEnd() {}
getXHR(): Type { return XHR; }
get attrToPropMap() { return _attrToPropMap; }
query(selector) { throw _notImplemented('query'); }