cleanup: move DomAdapter from angular2/core into angular2/platform/common_dom

BREAKING CHANGE

Before

import {DomAdapter} from 'angular2/core';

After

import {DomAdapter} from 'angular2/platform/common_dom';

Closes #5370
This commit is contained in:
vsavkin
2015-11-19 15:09:34 -08:00
committed by Victor Savkin
parent 4d59985b74
commit 3c8fa8c50d
76 changed files with 80 additions and 75 deletions

View File

@ -1,7 +1,7 @@
library angular.core.facade.dom;
import 'dart:html';
import 'package:angular2/core.dart' show setRootDomAdapter;
import 'package:angular2/platform/common_dom.dart' show setRootDomAdapter;
import 'generic_browser_adapter.dart' show GenericBrowserDomAdapter;
import 'package:angular2/src/facade/browser.dart';
import 'dart:js' as js;

View File

@ -1,6 +1,6 @@
import {MapWrapper, ListWrapper} from 'angular2/src/facade/collection';
import {isBlank, isPresent, global, setValueOnPath, DateWrapper} from 'angular2/src/facade/lang';
import {setRootDomAdapter} from 'angular2/src/core/dom/dom_adapter';
import {setRootDomAdapter} from 'angular2/src/platform/dom/dom_adapter';
import {GenericBrowserDomAdapter} from './generic_browser_adapter';
var _attrToPropMap = {

View File

@ -1,6 +1,6 @@
import {Type, isPresent, isBlank} from 'angular2/src/facade/lang';
import {Predicate} from 'angular2/src/facade/collection';
import {DOM} from 'angular2/src/core/dom/dom_adapter';
import {DOM} from 'angular2/src/platform/dom/dom_adapter';
import {DebugElement} from 'angular2/core';
export class By {

View File

@ -3,7 +3,7 @@ import {MapWrapper, Map, ListWrapper} from 'angular2/src/facade/collection';
import {Injectable, provide, Provider} from 'angular2/src/core/di';
import {AppViewListener} from 'angular2/src/core/linker/view_listener';
import {AppView} from 'angular2/src/core/linker/view';
import {DOM} from 'angular2/src/core/dom/dom_adapter';
import {DOM} from 'angular2/src/platform/dom/dom_adapter';
import {Renderer} from 'angular2/src/core/render/api';
import {DebugElement, DebugElement_} from 'angular2/src/core/debug/debug_element';

View File

@ -1,6 +1,6 @@
import {ListWrapper, StringMapWrapper} from 'angular2/src/facade/collection';
import {isPresent, isFunction, Type} from 'angular2/src/facade/lang';
import {DomAdapter} from 'angular2/src/core/dom/dom_adapter';
import {DomAdapter} from 'angular2/src/platform/dom/dom_adapter';
import {XHRImpl} from 'angular2/src/platform/browser/xhr_impl';

View File

@ -1,5 +1,5 @@
import {Promise, PromiseWrapper} from 'angular2/src/facade/async';
import {DomAdapter} from 'angular2/src/core/dom/dom_adapter';
import {DomAdapter} from 'angular2/src/platform/dom/dom_adapter';
import {ElementRef} from 'angular2/src/core/linker/element_ref';
export class Rectangle {

View File

@ -1,6 +1,7 @@
library testability.browser_testability;
import 'package:angular2/core.dart';
import 'package:angular2/platform/common_dom.dart';
import 'dart:html';
import 'dart:js' as js;

View File

@ -3,7 +3,7 @@ import {CONST, CONST_EXPR, global, isPresent} from 'angular2/src/facade/lang';
import {BaseException, WrappedException} from 'angular2/src/facade/exceptions';
import {PromiseWrapper, ObservableWrapper} from 'angular2/src/facade/async';
import {DOM} from 'angular2/src/core/dom/dom_adapter';
import {DOM} from 'angular2/src/platform/dom/dom_adapter';
import {
Injectable,

View File

@ -1,4 +1,4 @@
import {DOM} from 'angular2/src/core/dom/dom_adapter';
import {DOM} from 'angular2/src/platform/dom/dom_adapter';
/**
* A service that can be used to get and set the title of a current HTML document.

View File

@ -17,8 +17,7 @@ import {
import {COMMON_DIRECTIVES, COMMON_PIPES, FORM_PROVIDERS} from "angular2/common";
import {Renderer} from 'angular2/render';
import {Testability} from 'angular2/src/core/testability/testability';
import {DOM} from 'angular2/src/core/dom/dom_adapter';
import {DOM} from 'angular2/src/platform/dom/dom_adapter';
import {DomEventsPlugin} from 'angular2/src/platform/dom/events/dom_events';
import {KeyEventsPlugin} from 'angular2/src/platform/dom/events/key_events';
import {HammerGesturesPlugin} from 'angular2/src/platform/dom/events/hammer_gestures';

View File

@ -0,0 +1,135 @@
import {isBlank, Type} from 'angular2/src/facade/lang';
export var DOM: DomAdapter = null;
export function setRootDomAdapter(adapter: DomAdapter) {
if (isBlank(DOM)) {
DOM = adapter;
}
}
/* tslint:disable:requireParameterType */
/**
* Provides DOM operations in an environment-agnostic way.
*/
export abstract class DomAdapter {
abstract hasProperty(element, name: string): boolean;
abstract setProperty(el: Element, name: string, value: any);
abstract getProperty(el: Element, name: string): any;
abstract invoke(el: Element, methodName: string, args: any[]): any;
abstract logError(error);
abstract log(error);
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.
*/
attrToPropMap: {[key: string]: string};
abstract parse(templateHtml: string);
abstract query(selector: string): any;
abstract querySelector(el, selector: string): HTMLElement;
abstract querySelectorAll(el, selector: string): any[];
abstract on(el, evt, listener);
abstract onAndCancel(el, evt, listener): Function;
abstract dispatchEvent(el, evt);
abstract createMouseEvent(eventType): any;
abstract createEvent(eventType: string): any;
abstract preventDefault(evt);
abstract isPrevented(evt): boolean;
abstract getInnerHTML(el): string;
abstract getOuterHTML(el): string;
abstract nodeName(node): string;
abstract nodeValue(node): string;
abstract type(node): string;
abstract content(node): any;
abstract firstChild(el): Node;
abstract nextSibling(el): Node;
abstract parentElement(el): Node;
abstract childNodes(el): Node[];
abstract childNodesAsList(el): Node[];
abstract clearNodes(el);
abstract appendChild(el, node);
abstract removeChild(el, node);
abstract replaceChild(el, newNode, oldNode);
abstract remove(el): Node;
abstract insertBefore(el, node);
abstract insertAllBefore(el, nodes);
abstract insertAfter(el, node);
abstract setInnerHTML(el, value);
abstract getText(el): string;
abstract setText(el, value: string);
abstract getValue(el): string;
abstract setValue(el, value: string);
abstract getChecked(el): boolean;
abstract setChecked(el, value: boolean);
abstract createComment(text: string): any;
abstract createTemplate(html): HTMLElement;
abstract createElement(tagName, doc?): HTMLElement;
abstract createElementNS(ns: string, tagName: string, doc?): Element;
abstract createTextNode(text: string, doc?): Text;
abstract createScriptTag(attrName: string, attrValue: string, doc?): HTMLElement;
abstract createStyleElement(css: string, doc?): HTMLStyleElement;
abstract createShadowRoot(el): any;
abstract getShadowRoot(el): any;
abstract getHost(el): any;
abstract getDistributedNodes(el): Node[];
abstract clone /*<T extends Node>*/ (node: Node /*T*/): Node /*T*/;
abstract getElementsByClassName(element, name: string): HTMLElement[];
abstract getElementsByTagName(element, name: string): HTMLElement[];
abstract classList(element): any[];
abstract addClass(element, classname: string);
abstract removeClass(element, classname: string);
abstract hasClass(element, classname: string): boolean;
abstract setStyle(element, stylename: string, stylevalue: string);
abstract removeStyle(element, stylename: string);
abstract getStyle(element, stylename: string): string;
abstract tagName(element): string;
abstract attributeMap(element): Map<string, string>;
abstract hasAttribute(element, attribute: string): boolean;
abstract getAttribute(element, attribute: string): string;
abstract setAttribute(element, name: string, value: string);
abstract setAttributeNS(element, ns: string, name: string, value: string);
abstract removeAttribute(element, attribute: string);
abstract templateAwareRoot(el);
abstract createHtmlDocument(): HTMLDocument;
abstract defaultDoc(): HTMLDocument;
abstract getBoundingClientRect(el);
abstract getTitle(): string;
abstract setTitle(newTitle: string);
abstract elementMatches(n, selector: string): boolean;
abstract isTemplateElement(el: any): boolean;
abstract isTextNode(node): boolean;
abstract isCommentNode(node): boolean;
abstract isElementNode(node): boolean;
abstract hasShadowRoot(node): boolean;
abstract isShadowRoot(node): boolean;
abstract importIntoDoc /*<T extends Node>*/ (node: Node /*T*/): Node /*T*/;
abstract adoptNode /*<T extends Node>*/ (node: Node /*T*/): Node /*T*/;
abstract getHref(element): string;
abstract getEventKey(event): string;
abstract resolveAndSetHref(element, baseUrl: string, href: string);
abstract supportsDOMEvents(): boolean;
abstract supportsNativeShadowDOM(): boolean;
abstract getGlobalEventTarget(target: string): any;
abstract getHistory(): History;
abstract getLocation(): Location;
abstract getBaseHref(): string;
abstract resetBaseElement(): void;
abstract getUserAgent(): string;
abstract setData(element, name: string, value: string);
abstract getComputedStyle(element): any;
abstract getData(element, name: string): string;
abstract setGlobalVar(name: string, value: any);
abstract requestAnimationFrame(callback): number;
abstract cancelAnimationFrame(id);
abstract performanceNow(): number;
abstract getAnimationPrefix(): string;
abstract getTransitionEnd(): string;
abstract supportsAnimation(): boolean;
}

View File

@ -42,7 +42,7 @@ import {camelCaseToDashCase} from './util';
import {ViewEncapsulation} from 'angular2/src/core/metadata';
// TODO move it once DomAdapter is moved
import {DOM} from 'angular2/src/core/dom/dom_adapter';
import {DOM} from 'angular2/src/platform/dom/dom_adapter';
const NAMESPACE_URIS =
CONST_EXPR({'xlink': 'http://www.w3.org/1999/xlink', 'svg': 'http://www.w3.org/2000/svg'});

View File

@ -1,4 +1,4 @@
import {DOM} from 'angular2/src/core/dom/dom_adapter';
import {DOM} from 'angular2/src/platform/dom/dom_adapter';
import {Injectable, EventManagerPlugin, EventManager} from 'angular2/core';
@Injectable()

View File

@ -1,4 +1,4 @@
import {DOM} from 'angular2/src/core/dom/dom_adapter';
import {DOM} from 'angular2/src/platform/dom/dom_adapter';
import {
isPresent,
isBlank,

View File

@ -1,4 +1,4 @@
import {DOM} from 'angular2/src/core/dom/dom_adapter';
import {DOM} from 'angular2/src/platform/dom/dom_adapter';
import {Inject, Injectable} from 'angular2/src/core/di';
import {SetWrapper} from 'angular2/src/facade/collection';
import {DOCUMENT} from './dom_tokens';

View File

@ -3,7 +3,7 @@ library angular2.dom.abstractHtmlAdapter;
import 'package:html/parser.dart' as parser;
import 'package:html/dom.dart';
import 'package:angular2/core.dart';
import 'package:angular2/platform/common_dom.dart';
import 'package:angular2/src/compiler/xhr.dart';
const _attrToPropMap = const {

View File

@ -1,7 +1,7 @@
library angular2.dom.htmlAdapter;
import 'abstract_html_adapter.dart';
import 'package:angular2/core.dart' show setRootDomAdapter;
import 'package:angular2/platform/common_dom.dart';
import 'dart:io';
class Html5LibDomAdapter extends AbstractHtml5LibAdapter {

View File

@ -4,7 +4,7 @@ var serializer = new parse5.Serializer(parse5.TreeAdapters.htmlparser2);
var treeAdapter = parser.treeAdapter;
import {MapWrapper, ListWrapper, StringMapWrapper} from 'angular2/src/facade/collection';
import {DomAdapter, setRootDomAdapter} from 'angular2/core';
import {DomAdapter, setRootDomAdapter} from 'angular2/platform/common_dom';
import {
isPresent,
isBlank,

View File

@ -1,7 +1,7 @@
library angular2.dom.webWorkerAdapter;
import 'abstract_html_adapter.dart';
import 'package:angular2/core.dart' show setRootDomAdapter;
import 'package:angular2/platform/common_dom.dart';
class WebWorkerDomAdapter extends AbstractHtml5LibAdapter {
static void makeCurrent() {