refactor(core): move render/dom from core

Currently, core depends on DomRenderer, which depends on the browser.
This means that if you depend on angular2/core, you will always
pull in the browser dom adapter and the browser render, regardless
if you need them or not.

This PR moves the browser dom adapter and the browser renderer out of core.

BREAKING CHANGE

If you import browser adapter or dom renderer directly (not via angular2/core),
you will have to change the import path.
This commit is contained in:
vsavkin 2015-11-17 15:24:36 -08:00
parent 60a2bbb226
commit 2c8fcec432
120 changed files with 1163 additions and 806 deletions

View File

@ -12,4 +12,5 @@ export 'package:angular2/profile.dart';
export 'package:angular2/lifecycle_hooks.dart';
export 'package:angular2/src/core/application_tokens.dart'
hide APP_COMPONENT_REF_PROMISE, APP_ID_RANDOM_PROVIDER;
export 'package:angular2/src/core/render/dom/dom_tokens.dart';
export 'package:angular2/src/platform/dom/dom_tokens.dart';
export 'package:angular2/compiler.dart' show UrlResolver, AppRootUrl;

View File

@ -4,3 +4,4 @@ export * from './profile';
export * from './lifecycle_hooks';
export * from './platform/browser';
export * from './upgrade';
export {UrlResolver, AppRootUrl} from './compiler';

View File

@ -5,4 +5,5 @@
*/
export * from './src/compiler/url_resolver';
export * from './src/compiler/xhr';
export * from './src/compiler/compiler';
export * from './src/compiler/compiler';
export * from './src/compiler/app_root_url';

View File

@ -9,15 +9,16 @@ export 'package:angular2/src/common/pipes.dart';
export 'package:angular2/src/facade/facade.dart';
export 'package:angular2/src/core/application_ref.dart'
hide ApplicationRef_, PlatformRef_;
export 'package:angular2/src/core/services.dart';
export 'package:angular2/src/core/linker.dart';
export 'package:angular2/src/core/zone.dart';
export 'package:angular2/src/core/render.dart';
export 'package:angular2/src/common/directives.dart';
export 'package:angular2/src/common/forms.dart';
export 'package:angular2/src/core/debug.dart';
export 'package:angular2/src/core/debug/debug_element.dart' show DebugElement, Scope, inspectElement, asNativeElements;
export 'package:angular2/src/core/testability/testability.dart';
export 'package:angular2/src/core/change_detection.dart';
export 'package:angular2/src/core/platform_directives_and_pipes.dart';
export 'package:angular2/src/core/platform_common_providers.dart';
export 'package:angular2/src/core/application_common_providers.dart';
export 'package:angular2/src/core/reflection/reflection.dart';
export 'package:angular2/src/core/dom/dom_adapter.dart';

View File

@ -8,7 +8,6 @@ export * from './src/core/util';
export * from './src/core/di';
export * from './src/common/pipes';
export * from './src/facade/facade';
export * from './src/core/services';
export * from './src/core/linker';
export {platform, createNgZone, PlatformRef, ApplicationRef} from './src/core/application_ref';
export {APP_ID, APP_COMPONENT} from './src/core/application_tokens';
@ -16,10 +15,17 @@ export * from './src/core/zone';
export * from './src/core/render';
export * from './src/common/directives';
export * from './src/common/forms';
export * from './src/core/debug';
export {
DebugElement,
Scope,
inspectElement,
asNativeElements
} from './src/core/debug/debug_element';
export * from './src/core/testability/testability';
export * from './src/core/change_detection';
export * from './src/core/platform_directives_and_pipes';
export * from './src/core/dev_mode';
export * from './src/core/reflection/reflection';
export * from './src/core/application_common_providers';
export * from './src/core/platform_common_providers';
export * from './src/core/dom/dom_adapter';

View File

@ -1,4 +1,13 @@
export {BROWSER_PROVIDERS} from 'angular2/src/platform/browser_common';
export {
BROWSER_PROVIDERS,
ELEMENT_PROBE_BINDINGS,
ELEMENT_PROBE_PROVIDERS,
inspectNativeElement,
BrowserDomAdapter,
By,
Title,
DOCUMENT
} from 'angular2/src/platform/browser_common';
import {Type, isPresent, CONST_EXPR} from 'angular2/src/facade/lang';
import {Promise} from 'angular2/src/facade/promise';

View File

@ -1,4 +1,12 @@
export {BROWSER_PROVIDERS} from 'angular2/src/platform/browser_common';
export {
BROWSER_PROVIDERS,
ELEMENT_PROBE_BINDINGS,
ELEMENT_PROBE_PROVIDERS,
inspectNativeElement,
BrowserDomAdapter,
By,
Title
} from 'angular2/src/platform/browser_common';
import {Type, isPresent, CONST_EXPR} from 'angular2/src/facade/lang';
import {Promise} from 'angular2/src/facade/promise';

View File

@ -0,0 +1,7 @@
/**
* This is a set of classes and objects that can be used both in the browser and on the server.
*/
export {DomRenderer} from 'angular2/src/platform/dom/dom_renderer';
export {DOCUMENT} from 'angular2/src/platform/dom/dom_tokens';
export {SharedStylesHost, DomSharedStylesHost} from 'angular2/src/platform/dom/shared_styles_host';
export {DomEventsPlugin} from 'angular2/src/platform/dom/events/dom_events';

View File

@ -0,0 +1,2 @@
// TODO: vsavkin add SERVER_PROVIDERS and SERVER_APP_PROVIDERS
export 'package:angular2/src/platform/server/html_adapter.dart';

View File

@ -0,0 +1,2 @@
// TODO: vsavkin add SERVER_PROVIDERS and SERVER_APP_PROVIDERS
export {Parse5DomAdapter} from 'angular2/src/platform/server/parse5_adapter';

View File

@ -1,7 +1,4 @@
/**
* This file is only used for dart applications and for internal examples
* that compile with both JavaScript and Dart.
*
* JavaScript users should import from angular2/core.
* @deprecated import angular2/render/dom instead
*/
export * from './src/core/render';

View File

@ -6,7 +6,7 @@ import {
isPresent
} from 'angular2/src/facade/lang';
import {Math} from 'angular2/src/facade/math';
import {camelCaseToDashCase} from 'angular2/src/core/render/dom/util';
import {camelCaseToDashCase} from 'angular2/src/platform/dom/util';
import {StringMapWrapper} from 'angular2/src/facade/collection';
import {DOM} from 'angular2/src/core/dom/dom_adapter';

View File

@ -24,7 +24,7 @@ import {Compiler} from './linker/compiler';
import {Compiler_} from "./linker/compiler";
import {DynamicComponentLoader} from './linker/dynamic_component_loader';
import {DynamicComponentLoader_} from "./linker/dynamic_component_loader";
import {EventManager} from './render/dom/events/event_manager';
import {EventManager} from './render';
/**
* A default set of providers which should be included in any Angular

View File

@ -1,6 +0,0 @@
export {DebugElement, asNativeElements, By, Scope, inspectElement} from './debug/debug_element';
export {
inspectNativeElement,
ELEMENT_PROBE_PROVIDERS,
ELEMENT_PROBE_BINDINGS
} from './debug/debug_element_view_listener';

View File

@ -1,9 +1,6 @@
import {Type, isPresent, isBlank} from 'angular2/src/facade/lang';
import {ListWrapper, MapWrapper, Predicate} from 'angular2/src/facade/collection';
import {unimplemented} from 'angular2/src/facade/exceptions';
import {DOM} from 'angular2/src/core/dom/dom_adapter';
import {ElementInjector} from 'angular2/src/core/linker/element_injector';
import {AppView, ViewType} from 'angular2/src/core/linker/view';
import {internalView} from 'angular2/src/core/linker/view_ref';
@ -203,18 +200,3 @@ export class Scope {
return scope;
}
}
export class By {
static all(): Function { return (debugElement) => true; }
static css(selector: string): Predicate<DebugElement> {
return (debugElement) => {
return isPresent(debugElement.nativeElement) ?
DOM.elementMatches(debugElement.nativeElement, selector) :
false;
};
}
static directive(type: Type): Predicate<DebugElement> {
return (debugElement) => { return debugElement.hasDirective(type); };
}
}

View File

@ -20,7 +20,6 @@ import {FunctionWrapper, Type, isPresent, isBlank, CONST_EXPR} from 'angular2/sr
import {Key} from './key';
import {SelfMetadata, HostMetadata, SkipSelfMetadata} from './metadata';
// Threshold for the dynamic version
const _MAX_CONSTRUCTION_COUNTER = 10;

View File

@ -1,520 +1,4 @@
library angular.core.facade.dom;
@Deprecated('import this library from "package:angular2/platform/browser_static.dart"')
library angular2.browser_adapter_reexport;
import 'dart:html';
import 'dom_adapter.dart' show setRootDomAdapter;
import 'generic_browser_adapter.dart' show GenericBrowserDomAdapter;
import 'package:angular2/src/facade/browser.dart';
import 'dart:js' as js;
// WARNING: Do not expose outside this class. Parsing HTML using this
// sanitizer is a security risk.
class _IdentitySanitizer implements NodeTreeSanitizer {
void sanitizeTree(Node node) {}
}
final _identitySanitizer = new _IdentitySanitizer();
final _keyCodeToKeyMap = const {
8: 'Backspace',
9: 'Tab',
12: 'Clear',
13: 'Enter',
16: 'Shift',
17: 'Control',
18: 'Alt',
19: 'Pause',
20: 'CapsLock',
27: 'Escape',
32: ' ',
33: 'PageUp',
34: 'PageDown',
35: 'End',
36: 'Home',
37: 'ArrowLeft',
38: 'ArrowUp',
39: 'ArrowRight',
40: 'ArrowDown',
45: 'Insert',
46: 'Delete',
65: 'a',
66: 'b',
67: 'c',
68: 'd',
69: 'e',
70: 'f',
71: 'g',
72: 'h',
73: 'i',
74: 'j',
75: 'k',
76: 'l',
77: 'm',
78: 'n',
79: 'o',
80: 'p',
81: 'q',
82: 'r',
83: 's',
84: 't',
85: 'u',
86: 'v',
87: 'w',
88: 'x',
89: 'y',
90: 'z',
91: 'OS',
93: 'ContextMenu',
96: '0',
97: '1',
98: '2',
99: '3',
100: '4',
101: '5',
102: '6',
103: '7',
104: '8',
105: '9',
106: '*',
107: '+',
109: '-',
110: '.',
111: '/',
112: 'F1',
113: 'F2',
114: 'F3',
115: 'F4',
116: 'F5',
117: 'F6',
118: 'F7',
119: 'F8',
120: 'F9',
121: 'F10',
122: 'F11',
123: 'F12',
144: 'NumLock',
145: 'ScrollLock'
};
final bool _supportsTemplateElement = () {
try {
return new TemplateElement().content != null;
} catch (_) {
return false;
}
}();
class BrowserDomAdapter extends GenericBrowserDomAdapter {
js.JsFunction _setProperty;
js.JsFunction _getProperty;
js.JsFunction _hasProperty;
Map<String, bool> _hasPropertyCache;
BrowserDomAdapter() {
_hasPropertyCache = new Map();
_setProperty = js.context.callMethod(
'eval', ['(function(el, prop, value) { el[prop] = value; })']);
_getProperty = js.context
.callMethod('eval', ['(function(el, prop) { return el[prop]; })']);
_hasProperty = js.context
.callMethod('eval', ['(function(el, prop) { return prop in el; })']);
}
static void makeCurrent() {
setRootDomAdapter(new BrowserDomAdapter());
}
bool hasProperty(Element element, String name) {
// Always return true as the serverside version html_adapter.dart does so.
// TODO: change this once we have schema support.
// Note: This nees to kept in sync with html_adapter.dart!
return true;
}
void setProperty(Element element, String name, Object value) {
var cacheKey = "${element.tagName}.${name}";
var hasProperty = this._hasPropertyCache[cacheKey];
if (hasProperty == null) {
hasProperty = this._hasProperty.apply([element, name]);
this._hasPropertyCache[cacheKey] = hasProperty;
}
if (hasProperty) {
_setProperty.apply([element, name, value]);
}
}
getProperty(Element element, String name) =>
_getProperty.apply([element, name]);
invoke(Element element, String methodName, List args) =>
this.getProperty(element, methodName).apply(args, thisArg: element);
// TODO(tbosch): move this into a separate environment class once we have it
logError(error) {
window.console.error(error);
}
log(error) {
window.console.log(error);
}
logGroup(error) {
window.console.group(error);
this.logError(error);
}
logGroupEnd() {
window.console.groupEnd();
}
@override
Map<String, String> get attrToPropMap => const <String, String>{
'class': 'className',
'innerHtml': 'innerHTML',
'readonly': 'readOnly',
'tabindex': 'tabIndex',
};
Element query(String selector) => document.querySelector(selector);
Element querySelector(el, String selector) => el.querySelector(selector);
ElementList querySelectorAll(el, String selector) =>
el.querySelectorAll(selector);
void on(EventTarget element, String event, callback(arg)) {
// due to https://code.google.com/p/dart/issues/detail?id=17406
// addEventListener misses zones so we use element.on.
element.on[event].listen(callback);
}
Function onAndCancel(EventTarget element, String event, callback(arg)) {
// due to https://code.google.com/p/dart/issues/detail?id=17406
// addEventListener misses zones so we use element.on.
var subscription = element.on[event].listen(callback);
return subscription.cancel;
}
void dispatchEvent(EventTarget el, Event evt) {
el.dispatchEvent(evt);
}
MouseEvent createMouseEvent(String eventType) =>
new MouseEvent(eventType, canBubble: true);
Event createEvent(String eventType) => new Event(eventType, canBubble: true);
void preventDefault(Event evt) {
evt.preventDefault();
}
bool isPrevented(Event evt) {
return evt.defaultPrevented;
}
String getInnerHTML(Element el) => el.innerHtml;
String getOuterHTML(Element el) => el.outerHtml;
void setInnerHTML(Element el, String value) {
el.innerHtml = value;
}
String nodeName(Node el) => el.nodeName;
String nodeValue(Node el) => el.nodeValue;
String type(InputElement el) => el.type;
Node content(TemplateElement el) =>
_supportsTemplateElement ? el.content : el;
Node firstChild(el) => el.firstChild;
Node nextSibling(Node el) => el.nextNode;
Element parentElement(Node el) => el.parent;
List<Node> childNodes(Node el) => el.childNodes;
List childNodesAsList(Node el) => childNodes(el).toList();
void clearNodes(Node el) {
el.nodes = const [];
}
void appendChild(Node el, Node node) {
el.append(node);
}
void removeChild(el, Node node) {
node.remove();
}
void replaceChild(Node el, Node newNode, Node oldNode) {
oldNode.replaceWith(newNode);
}
ChildNode remove(ChildNode el) {
return el..remove();
}
void insertBefore(Node el, node) {
el.parentNode.insertBefore(node, el);
}
void insertAllBefore(Node el, Iterable<Node> nodes) {
el.parentNode.insertAllBefore(nodes, el);
}
void insertAfter(Node el, Node node) {
el.parentNode.insertBefore(node, el.nextNode);
}
String getText(Node el) => el.text;
void setText(Node el, String value) {
el.text = value;
}
String getValue(el) => el.value;
void setValue(el, String value) {
el.value = value;
}
bool getChecked(InputElement el) => el.checked;
void setChecked(InputElement el, bool isChecked) {
el.checked = isChecked;
}
Comment createComment(String text) {
return new Comment(text);
}
TemplateElement createTemplate(String html) {
var t = new TemplateElement();
// We do not sanitize because templates are part of the application code
// not user code.
t.setInnerHtml(html, treeSanitizer: _identitySanitizer);
return t;
}
Element createElement(String tagName, [HtmlDocument doc = null]) {
if (doc == null) doc = document;
return doc.createElement(tagName);
}
Element createElementNS(String ns, String tagName, [HtmlDocument doc = null]) {
if (doc == null) doc = document;
return doc.createElementNS(ns, tagName);
}
Text createTextNode(String text, [HtmlDocument doc = null]) {
return new Text(text);
}
createScriptTag(String attrName, String attrValue,
[HtmlDocument doc = null]) {
if (doc == null) doc = document;
var el = doc.createElement('SCRIPT');
el.setAttribute(attrName, attrValue);
return el;
}
StyleElement createStyleElement(String css, [HtmlDocument doc = null]) {
if (doc == null) doc = document;
var el = doc.createElement('STYLE');
el.text = css;
return el;
}
ShadowRoot createShadowRoot(Element el) => el.createShadowRoot();
ShadowRoot getShadowRoot(Element el) => el.shadowRoot;
Element getHost(Element el) => (el as ShadowRoot).host;
clone(Node node) => node.clone(true);
List<Node> getElementsByClassName(Element element, String name) =>
element.getElementsByClassName(name);
List<Node> getElementsByTagName(Element element, String name) =>
element.querySelectorAll(name);
List<String> classList(Element element) => element.classes.toList();
void addClass(Element element, String classname) {
element.classes.add(classname);
}
void removeClass(Element element, String classname) {
element.classes.remove(classname);
}
bool hasClass(Element element, String classname) =>
element.classes.contains(classname);
void setStyle(Element element, String stylename, String stylevalue) {
element.style.setProperty(stylename, stylevalue);
}
void removeStyle(Element element, String stylename) {
element.style.removeProperty(stylename);
}
String getStyle(Element element, String stylename) {
return element.style.getPropertyValue(stylename);
}
String tagName(Element element) => element.tagName;
Map<String, String> attributeMap(Element element) {
var result = {};
result.addAll(element.attributes);
// TODO(tbosch): element.getNamespacedAttributes() somehow does not return the attribute value
var xlinkHref = element.getAttributeNS('http://www.w3.org/1999/xlink', 'href');
if (xlinkHref != null) {
result['xlink:href'] = xlinkHref;
}
return result;
}
bool hasAttribute(Element element, String attribute) =>
element.attributes.containsKey(attribute);
String getAttribute(Element element, String attribute) =>
element.getAttribute(attribute);
void setAttribute(Element element, String name, String value) {
element.setAttribute(name, value);
}
void setAttributeNS(Element element, String ns, String name, String value) {
element.setAttributeNS(ns, name, value);
}
void removeAttribute(Element element, String name) {
//there is no removeAttribute method as of now in Dart:
//https://code.google.com/p/dart/issues/detail?id=19934
element.attributes.remove(name);
}
Node templateAwareRoot(Element el) => el is TemplateElement ? el.content : el;
HtmlDocument createHtmlDocument() =>
document.implementation.createHtmlDocument('fakeTitle');
HtmlDocument defaultDoc() => document;
Rectangle getBoundingClientRect(el) => el.getBoundingClientRect();
String getTitle() => document.title;
void setTitle(String newTitle) {
document.title = newTitle;
}
bool elementMatches(n, String selector) =>
n is Element && n.matches(selector);
bool isTemplateElement(Element el) => el is TemplateElement;
bool isTextNode(Node node) => node.nodeType == Node.TEXT_NODE;
bool isCommentNode(Node node) => node.nodeType == Node.COMMENT_NODE;
bool isElementNode(Node node) => node.nodeType == Node.ELEMENT_NODE;
bool hasShadowRoot(Node node) {
return node is Element && node.shadowRoot != null;
}
bool isShadowRoot(Node node) {
return node is ShadowRoot;
}
Node importIntoDoc(Node node) {
return document.importNode(node, true);
}
Node adoptNode(Node node) {
return document.adoptNode(node);
}
String getHref(AnchorElement element) {
return element.href;
}
String getEventKey(KeyboardEvent event) {
int keyCode = event.keyCode;
return _keyCodeToKeyMap.containsKey(keyCode)
? _keyCodeToKeyMap[keyCode]
: 'Unidentified';
}
getGlobalEventTarget(String target) {
if (target == "window") {
return window;
} else if (target == "document") {
return document;
} else if (target == "body") {
return document.body;
}
}
getHistory() {
return window.history;
}
getLocation() {
return window.location;
}
String getBaseHref() {
var href = getBaseElementHref();
if (href == null) {
return null;
}
return _relativePath(href);
}
resetBaseElement() {
baseElement = null;
}
String getUserAgent() {
return window.navigator.userAgent;
}
void setData(Element element, String name, String value) {
element.dataset[name] = value;
}
String getData(Element element, String name) {
return element.dataset[name];
}
getComputedStyle(elem) => elem.getComputedStyle();
// TODO(tbosch): move this into a separate environment class once we have it
setGlobalVar(String path, value) {
var parts = path.split('.');
var obj = js.context;
while (parts.length > 1) {
var name = parts.removeAt(0);
if (obj.hasProperty(name)) {
obj = obj[name];
} else {
obj = obj[name] = new js.JsObject(js.context['Object']);
}
}
obj[parts.removeAt(0)] = value;
}
requestAnimationFrame(callback) {
return window.requestAnimationFrame(callback);
}
cancelAnimationFrame(id) {
window.cancelAnimationFrame(id);
}
num performanceNow() {
return window.performance.now();
}
parse(s) {
throw 'not implemented';
}
}
var baseElement = null;
String getBaseElementHref() {
if (baseElement == null) {
baseElement = document.querySelector('base');
if (baseElement == null) {
return null;
}
}
return baseElement.getAttribute('href');
}
// based on urlUtils.js in AngularJS 1
AnchorElement _urlParsingNode = null;
String _relativePath(String url) {
if (_urlParsingNode == null) {
_urlParsingNode = new AnchorElement();
}
_urlParsingNode.href = url;
var pathname = _urlParsingNode.pathname;
return (pathname[0] == '/') ? pathname : '/${pathname}';
}
export 'package:angular2/src/platform/browser/browser_adapter.dart';

View File

@ -1,6 +1,6 @@
import {isBlank, Type} from 'angular2/src/facade/lang';
export var DOM: DomAdapter;
export var DOM: DomAdapter = null;
export function setRootDomAdapter(adapter: DomAdapter) {
if (isBlank(DOM)) {

View File

@ -19,4 +19,4 @@ export {ElementRef} from './linker/element_ref';
export {TemplateRef} from './linker/template_ref';
export {ViewRef, HostViewRef, ProtoViewRef} from './linker/view_ref';
export {ViewContainerRef} from './linker/view_container_ref';
export {ComponentRef} from './linker/dynamic_component_loader';
export {ComponentRef} from './linker/dynamic_component_loader';

View File

@ -30,7 +30,7 @@ import {
NgContentCmd
} from './template_commands';
import {Renderer} from 'angular2/render';
import {Renderer} from 'angular2/src/core/render/api';
import {APP_ID} from 'angular2/src/core/application_tokens';

View File

@ -8,7 +8,7 @@ import {
RenderNgContentCmd,
RenderBeginComponentCmd,
RenderEmbeddedTemplateCmd
} from 'angular2/src/core/render/render';
} from 'angular2/src/core/render/api';
import {ViewEncapsulation} from 'angular2/src/core/metadata';
// Export ViewEncapsulation so that compiled templates only need to depend
// on template_commands.

View File

@ -28,7 +28,7 @@ import {RenderEventDispatcher} from 'angular2/src/core/render/api';
import {ViewRef, ProtoViewRef, internalView} from './view_ref';
import {ElementRef} from './element_ref';
import {ProtoPipes} from 'angular2/src/core/pipes/pipes';
import {camelCaseToDashCase} from 'angular2/src/core/render/dom/util';
import {camelCaseToDashCase} from 'angular2/src/core/render/util';
import {TemplateCmd} from './template_commands';
import {ViewRef_, ProtoViewRef_} from "./view_ref";

View File

@ -7,7 +7,6 @@ export {
RenderProtoViewRef,
RenderFragmentRef,
RenderViewWithFragments,
DOCUMENT,
RenderTemplateCmd,
RenderCommandVisitor,
RenderTextCmd,
@ -15,5 +14,8 @@ export {
RenderBeginElementCmd,
RenderBeginComponentCmd,
RenderEmbeddedTemplateCmd,
RenderBeginCmd
} from './render/render';
RenderBeginCmd,
RenderComponentTemplate
} from './render/api';
export {EventManager, EventManagerPlugin, EVENT_MANAGER_PLUGINS} from './render/event_manager';

View File

@ -1,9 +1,8 @@
import {CONST_EXPR} from 'angular2/src/facade/lang';
import {BaseException, WrappedException} from 'angular2/src/facade/exceptions';
import {ListWrapper} from 'angular2/src/facade/collection';
import {DOM} from 'angular2/src/core/dom/dom_adapter';
import {NgZone} from 'angular2/src/core/zone/ng_zone';
import {Injectable, Inject, OpaqueToken} from 'angular2/src/core/di';
import {NgZone} from 'angular2/src/core/zone/ng_zone';
import {ListWrapper} from 'angular2/src/facade/collection';
export const EVENT_MANAGER_PLUGINS: OpaqueToken =
CONST_EXPR(new OpaqueToken("EventManagerPlugins"));
@ -55,27 +54,4 @@ export class EventManagerPlugin {
addGlobalEventListener(element: string, eventName: string, handler: Function): Function {
throw "not implemented";
}
}
@Injectable()
export class DomEventsPlugin extends EventManagerPlugin {
manager: EventManager;
// This plugin should come last in the list of plugins, because it accepts all
// events.
supports(eventName: string): boolean { return true; }
addEventListener(element: HTMLElement, eventName: string, handler: Function) {
var zone = this.manager.getZone();
var outsideHandler = (event) => zone.run(() => handler(event));
this.manager.getZone().runOutsideAngular(() => { DOM.on(element, eventName, outsideHandler); });
}
addGlobalEventListener(target: string, eventName: string, handler: Function): Function {
var element = DOM.getGlobalEventTarget(target);
var zone = this.manager.getZone();
var outsideHandler = (event) => zone.run(() => handler(event));
return this.manager.getZone().runOutsideAngular(
() => { return DOM.onAndCancel(element, eventName, outsideHandler); });
}
}
}

View File

@ -1,10 +0,0 @@
/**
* @module
* @description
* This module provides advanced support for extending dom strategy.
*/
export * from './dom/shared_styles_host';
export * from './dom/dom_renderer';
export * from './dom/dom_tokens';
export * from './api';

View File

@ -1,4 +0,0 @@
// Public API for Services
export {AppRootUrl} from 'angular2/src/compiler/app_root_url';
export {UrlResolver} from 'angular2/src/compiler/url_resolver';
export {Title} from 'angular2/src/core/services/title';

View File

@ -1,5 +1,4 @@
import {Injectable} from 'angular2/src/core/di';
import {DOM} from 'angular2/src/core/dom/dom_adapter';
import {Map, MapWrapper, ListWrapper} from 'angular2/src/facade/collection';
import {CONST, CONST_EXPR} from 'angular2/src/facade/lang';
import {BaseException, WrappedException} from 'angular2/src/facade/exceptions';
@ -94,39 +93,38 @@ export class TestabilityRegistry {
/** @internal */
_applications = new Map<any, Testability>();
constructor() { testabilityGetter.addToWindow(this); }
constructor() { _testabilityGetter.addToWindow(this); }
registerApplication(token: any, testability: Testability) {
this._applications.set(token, testability);
}
getTestability(elem: any): Testability { return this._applications.get(elem); }
getAllTestabilities(): Testability[] { return MapWrapper.values(this._applications); }
findTestabilityInTree(elem: Node, findInAncestors: boolean = true): Testability {
if (elem == null) {
return null;
}
if (this._applications.has(elem)) {
return this._applications.get(elem);
} else if (!findInAncestors) {
return null;
}
if (DOM.isShadowRoot(elem)) {
return this.findTestabilityInTree(DOM.getHost(elem));
}
return this.findTestabilityInTree(DOM.parentElement(elem));
return _testabilityGetter.findTestabilityInTree(this, elem, findInAncestors);
}
}
export interface GetTestability { addToWindow(registry: TestabilityRegistry): void; }
export interface GetTestability {
addToWindow(registry: TestabilityRegistry): void;
findTestabilityInTree(registry: TestabilityRegistry, elem: any,
findInAncestors: boolean): Testability;
}
@CONST()
class NoopGetTestability implements GetTestability {
class _NoopGetTestability implements GetTestability {
addToWindow(registry: TestabilityRegistry): void {}
findTestabilityInTree(registry: TestabilityRegistry, elem: any,
findInAncestors: boolean): Testability {
return null;
}
}
export function setTestabilityGetter(getter: GetTestability): void {
testabilityGetter = getter;
_testabilityGetter = getter;
}
var testabilityGetter: GetTestability = CONST_EXPR(new NoopGetTestability());
var _testabilityGetter: GetTestability = CONST_EXPR(new _NoopGetTestability());

View File

@ -0,0 +1,520 @@
library angular.core.facade.dom;
import 'dart:html';
import 'package:angular2/core.dart' show setRootDomAdapter;
import 'generic_browser_adapter.dart' show GenericBrowserDomAdapter;
import 'package:angular2/src/facade/browser.dart';
import 'dart:js' as js;
// WARNING: Do not expose outside this class. Parsing HTML using this
// sanitizer is a security risk.
class _IdentitySanitizer implements NodeTreeSanitizer {
void sanitizeTree(Node node) {}
}
final _identitySanitizer = new _IdentitySanitizer();
final _keyCodeToKeyMap = const {
8: 'Backspace',
9: 'Tab',
12: 'Clear',
13: 'Enter',
16: 'Shift',
17: 'Control',
18: 'Alt',
19: 'Pause',
20: 'CapsLock',
27: 'Escape',
32: ' ',
33: 'PageUp',
34: 'PageDown',
35: 'End',
36: 'Home',
37: 'ArrowLeft',
38: 'ArrowUp',
39: 'ArrowRight',
40: 'ArrowDown',
45: 'Insert',
46: 'Delete',
65: 'a',
66: 'b',
67: 'c',
68: 'd',
69: 'e',
70: 'f',
71: 'g',
72: 'h',
73: 'i',
74: 'j',
75: 'k',
76: 'l',
77: 'm',
78: 'n',
79: 'o',
80: 'p',
81: 'q',
82: 'r',
83: 's',
84: 't',
85: 'u',
86: 'v',
87: 'w',
88: 'x',
89: 'y',
90: 'z',
91: 'OS',
93: 'ContextMenu',
96: '0',
97: '1',
98: '2',
99: '3',
100: '4',
101: '5',
102: '6',
103: '7',
104: '8',
105: '9',
106: '*',
107: '+',
109: '-',
110: '.',
111: '/',
112: 'F1',
113: 'F2',
114: 'F3',
115: 'F4',
116: 'F5',
117: 'F6',
118: 'F7',
119: 'F8',
120: 'F9',
121: 'F10',
122: 'F11',
123: 'F12',
144: 'NumLock',
145: 'ScrollLock'
};
final bool _supportsTemplateElement = () {
try {
return new TemplateElement().content != null;
} catch (_) {
return false;
}
}();
class BrowserDomAdapter extends GenericBrowserDomAdapter {
js.JsFunction _setProperty;
js.JsFunction _getProperty;
js.JsFunction _hasProperty;
Map<String, bool> _hasPropertyCache;
BrowserDomAdapter() {
_hasPropertyCache = new Map();
_setProperty = js.context.callMethod(
'eval', ['(function(el, prop, value) { el[prop] = value; })']);
_getProperty = js.context
.callMethod('eval', ['(function(el, prop) { return el[prop]; })']);
_hasProperty = js.context
.callMethod('eval', ['(function(el, prop) { return prop in el; })']);
}
static void makeCurrent() {
setRootDomAdapter(new BrowserDomAdapter());
}
bool hasProperty(Element element, String name) {
// Always return true as the serverside version html_adapter.dart does so.
// TODO: change this once we have schema support.
// Note: This nees to kept in sync with html_adapter.dart!
return true;
}
void setProperty(Element element, String name, Object value) {
var cacheKey = "${element.tagName}.${name}";
var hasProperty = this._hasPropertyCache[cacheKey];
if (hasProperty == null) {
hasProperty = this._hasProperty.apply([element, name]);
this._hasPropertyCache[cacheKey] = hasProperty;
}
if (hasProperty) {
_setProperty.apply([element, name, value]);
}
}
getProperty(Element element, String name) =>
_getProperty.apply([element, name]);
invoke(Element element, String methodName, List args) =>
this.getProperty(element, methodName).apply(args, thisArg: element);
// TODO(tbosch): move this into a separate environment class once we have it
logError(error) {
window.console.error(error);
}
log(error) {
window.console.log(error);
}
logGroup(error) {
window.console.group(error);
this.logError(error);
}
logGroupEnd() {
window.console.groupEnd();
}
@override
Map<String, String> get attrToPropMap => const <String, String>{
'class': 'className',
'innerHtml': 'innerHTML',
'readonly': 'readOnly',
'tabindex': 'tabIndex',
};
Element query(String selector) => document.querySelector(selector);
Element querySelector(el, String selector) => el.querySelector(selector);
ElementList querySelectorAll(el, String selector) =>
el.querySelectorAll(selector);
void on(EventTarget element, String event, callback(arg)) {
// due to https://code.google.com/p/dart/issues/detail?id=17406
// addEventListener misses zones so we use element.on.
element.on[event].listen(callback);
}
Function onAndCancel(EventTarget element, String event, callback(arg)) {
// due to https://code.google.com/p/dart/issues/detail?id=17406
// addEventListener misses zones so we use element.on.
var subscription = element.on[event].listen(callback);
return subscription.cancel;
}
void dispatchEvent(EventTarget el, Event evt) {
el.dispatchEvent(evt);
}
MouseEvent createMouseEvent(String eventType) =>
new MouseEvent(eventType, canBubble: true);
Event createEvent(String eventType) => new Event(eventType, canBubble: true);
void preventDefault(Event evt) {
evt.preventDefault();
}
bool isPrevented(Event evt) {
return evt.defaultPrevented;
}
String getInnerHTML(Element el) => el.innerHtml;
String getOuterHTML(Element el) => el.outerHtml;
void setInnerHTML(Element el, String value) {
el.innerHtml = value;
}
String nodeName(Node el) => el.nodeName;
String nodeValue(Node el) => el.nodeValue;
String type(InputElement el) => el.type;
Node content(TemplateElement el) =>
_supportsTemplateElement ? el.content : el;
Node firstChild(el) => el.firstChild;
Node nextSibling(Node el) => el.nextNode;
Element parentElement(Node el) => el.parent;
List<Node> childNodes(Node el) => el.childNodes;
List childNodesAsList(Node el) => childNodes(el).toList();
void clearNodes(Node el) {
el.nodes = const [];
}
void appendChild(Node el, Node node) {
el.append(node);
}
void removeChild(el, Node node) {
node.remove();
}
void replaceChild(Node el, Node newNode, Node oldNode) {
oldNode.replaceWith(newNode);
}
ChildNode remove(ChildNode el) {
return el..remove();
}
void insertBefore(Node el, node) {
el.parentNode.insertBefore(node, el);
}
void insertAllBefore(Node el, Iterable<Node> nodes) {
el.parentNode.insertAllBefore(nodes, el);
}
void insertAfter(Node el, Node node) {
el.parentNode.insertBefore(node, el.nextNode);
}
String getText(Node el) => el.text;
void setText(Node el, String value) {
el.text = value;
}
String getValue(el) => el.value;
void setValue(el, String value) {
el.value = value;
}
bool getChecked(InputElement el) => el.checked;
void setChecked(InputElement el, bool isChecked) {
el.checked = isChecked;
}
Comment createComment(String text) {
return new Comment(text);
}
TemplateElement createTemplate(String html) {
var t = new TemplateElement();
// We do not sanitize because templates are part of the application code
// not user code.
t.setInnerHtml(html, treeSanitizer: _identitySanitizer);
return t;
}
Element createElement(String tagName, [HtmlDocument doc = null]) {
if (doc == null) doc = document;
return doc.createElement(tagName);
}
Element createElementNS(String ns, String tagName, [HtmlDocument doc = null]) {
if (doc == null) doc = document;
return doc.createElementNS(ns, tagName);
}
Text createTextNode(String text, [HtmlDocument doc = null]) {
return new Text(text);
}
createScriptTag(String attrName, String attrValue,
[HtmlDocument doc = null]) {
if (doc == null) doc = document;
var el = doc.createElement('SCRIPT');
el.setAttribute(attrName, attrValue);
return el;
}
StyleElement createStyleElement(String css, [HtmlDocument doc = null]) {
if (doc == null) doc = document;
var el = doc.createElement('STYLE');
el.text = css;
return el;
}
ShadowRoot createShadowRoot(Element el) => el.createShadowRoot();
ShadowRoot getShadowRoot(Element el) => el.shadowRoot;
Element getHost(Element el) => (el as ShadowRoot).host;
clone(Node node) => node.clone(true);
List<Node> getElementsByClassName(Element element, String name) =>
element.getElementsByClassName(name);
List<Node> getElementsByTagName(Element element, String name) =>
element.querySelectorAll(name);
List<String> classList(Element element) => element.classes.toList();
void addClass(Element element, String classname) {
element.classes.add(classname);
}
void removeClass(Element element, String classname) {
element.classes.remove(classname);
}
bool hasClass(Element element, String classname) =>
element.classes.contains(classname);
void setStyle(Element element, String stylename, String stylevalue) {
element.style.setProperty(stylename, stylevalue);
}
void removeStyle(Element element, String stylename) {
element.style.removeProperty(stylename);
}
String getStyle(Element element, String stylename) {
return element.style.getPropertyValue(stylename);
}
String tagName(Element element) => element.tagName;
Map<String, String> attributeMap(Element element) {
var result = {};
result.addAll(element.attributes);
// TODO(tbosch): element.getNamespacedAttributes() somehow does not return the attribute value
var xlinkHref = element.getAttributeNS('http://www.w3.org/1999/xlink', 'href');
if (xlinkHref != null) {
result['xlink:href'] = xlinkHref;
}
return result;
}
bool hasAttribute(Element element, String attribute) =>
element.attributes.containsKey(attribute);
String getAttribute(Element element, String attribute) =>
element.getAttribute(attribute);
void setAttribute(Element element, String name, String value) {
element.setAttribute(name, value);
}
void setAttributeNS(Element element, String ns, String name, String value) {
element.setAttributeNS(ns, name, value);
}
void removeAttribute(Element element, String name) {
//there is no removeAttribute method as of now in Dart:
//https://code.google.com/p/dart/issues/detail?id=19934
element.attributes.remove(name);
}
Node templateAwareRoot(Element el) => el is TemplateElement ? el.content : el;
HtmlDocument createHtmlDocument() =>
document.implementation.createHtmlDocument('fakeTitle');
HtmlDocument defaultDoc() => document;
Rectangle getBoundingClientRect(el) => el.getBoundingClientRect();
String getTitle() => document.title;
void setTitle(String newTitle) {
document.title = newTitle;
}
bool elementMatches(n, String selector) =>
n is Element && n.matches(selector);
bool isTemplateElement(Element el) => el is TemplateElement;
bool isTextNode(Node node) => node.nodeType == Node.TEXT_NODE;
bool isCommentNode(Node node) => node.nodeType == Node.COMMENT_NODE;
bool isElementNode(Node node) => node.nodeType == Node.ELEMENT_NODE;
bool hasShadowRoot(Node node) {
return node is Element && node.shadowRoot != null;
}
bool isShadowRoot(Node node) {
return node is ShadowRoot;
}
Node importIntoDoc(Node node) {
return document.importNode(node, true);
}
Node adoptNode(Node node) {
return document.adoptNode(node);
}
String getHref(AnchorElement element) {
return element.href;
}
String getEventKey(KeyboardEvent event) {
int keyCode = event.keyCode;
return _keyCodeToKeyMap.containsKey(keyCode)
? _keyCodeToKeyMap[keyCode]
: 'Unidentified';
}
getGlobalEventTarget(String target) {
if (target == "window") {
return window;
} else if (target == "document") {
return document;
} else if (target == "body") {
return document.body;
}
}
getHistory() {
return window.history;
}
getLocation() {
return window.location;
}
String getBaseHref() {
var href = getBaseElementHref();
if (href == null) {
return null;
}
return _relativePath(href);
}
resetBaseElement() {
baseElement = null;
}
String getUserAgent() {
return window.navigator.userAgent;
}
void setData(Element element, String name, String value) {
element.dataset[name] = value;
}
String getData(Element element, String name) {
return element.dataset[name];
}
getComputedStyle(elem) => elem.getComputedStyle();
// TODO(tbosch): move this into a separate environment class once we have it
setGlobalVar(String path, value) {
var parts = path.split('.');
var obj = js.context;
while (parts.length > 1) {
var name = parts.removeAt(0);
if (obj.hasProperty(name)) {
obj = obj[name];
} else {
obj = obj[name] = new js.JsObject(js.context['Object']);
}
}
obj[parts.removeAt(0)] = value;
}
requestAnimationFrame(callback) {
return window.requestAnimationFrame(callback);
}
cancelAnimationFrame(id) {
window.cancelAnimationFrame(id);
}
num performanceNow() {
return window.performance.now();
}
parse(s) {
throw 'not implemented';
}
}
var baseElement = null;
String getBaseElementHref() {
if (baseElement == null) {
baseElement = document.querySelector('base');
if (baseElement == null) {
return null;
}
}
return baseElement.getAttribute('href');
}
// based on urlUtils.js in AngularJS 1
AnchorElement _urlParsingNode = null;
String _relativePath(String url) {
if (_urlParsingNode == null) {
_urlParsingNode = new AnchorElement();
}
_urlParsingNode.href = url;
var pathname = _urlParsingNode.pathname;
return (pathname[0] == '/') ? pathname : '/${pathname}';
}

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 './dom_adapter';
import {setRootDomAdapter} from 'angular2/src/core/dom/dom_adapter';
import {GenericBrowserDomAdapter} from './generic_browser_adapter';
var _attrToPropMap = {

View File

@ -0,0 +1,19 @@
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 {DebugElement} from 'angular2/core';
export class By {
static all(): Function { return (debugElement) => true; }
static css(selector: string): Predicate<DebugElement> {
return (debugElement) => {
return isPresent(debugElement.nativeElement) ?
DOM.elementMatches(debugElement.nativeElement, selector) :
false;
};
}
static directive(type: Type): Predicate<DebugElement> {
return (debugElement) => { return debugElement.hasDirective(type); };
}
}

View File

@ -5,7 +5,7 @@ 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 {Renderer} from 'angular2/src/core/render/api';
import {DebugElement, DebugElement_} from './debug_element';
import {DebugElement, DebugElement_} from 'angular2/src/core/debug/debug_element';
const NG_ID_PROPERTY = 'ngid';
const INSPECT_GLOBAL_NAME = 'ng.probe';

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 './dom_adapter';
import {DomAdapter} from 'angular2/src/core/dom/dom_adapter';
import {XHRImpl} from 'angular2/src/platform/browser/xhr_impl';

View File

@ -1,6 +1,6 @@
library testability.browser_testability;
import './testability.dart';
import 'package:angular2/core.dart';
import 'dart:html';
import 'dart:js' as js;
@ -107,20 +107,20 @@ class BrowserGetTestability implements GetTestability {
js.context['ngTestabilityRegistries'] = jsRegistry = new js.JsArray();
js.context['getAngularTestability'] =
_jsify((Element elem, [bool findInAncestors = true]) {
var registry = js.context['ngTestabilityRegistries'];
for (int i = 0; i < registry.length; i++) {
var result = registry[i]
.callMethod('getAngularTestability', [elem, findInAncestors]);
if (result != null) return result;
}
throw 'Could not find testability for element.';
});
var registry = js.context['ngTestabilityRegistries'];
for (int i = 0; i < registry.length; i++) {
var result = registry[i]
.callMethod('getAngularTestability', [elem, findInAncestors]);
if (result != null) return result;
}
throw 'Could not find testability for element.';
});
js.context['getAllAngularTestabilities'] = _jsify(() {
var registry = js.context['ngTestabilityRegistries'];
var result = [];
for (int i = 0; i < registry.length; i++) {
var testabilities =
registry[i].callMethod('getAllAngularTestabilities');
registry[i].callMethod('getAllAngularTestabilities');
if (testabilities != null) result.addAll(testabilities);
}
return _jsify(result);
@ -129,15 +129,31 @@ class BrowserGetTestability implements GetTestability {
jsRegistry.add(this._createRegistry(registry));
}
findTestabilityInTree(TestabilityRegistry registry, dynamic elem, bool findInAncestors) {
if (elem == null) {
return null;
}
var t = registry.getTestability(elem);
if (t != null) {
return t;
} else if (!findInAncestors) {
return null;
}
if (DOM.isShadowRoot(elem)) {
return this.findTestabilityInTree(registry, DOM.getHost(elem), true);
}
return this.findTestabilityInTree(registry, DOM.parentElement(elem), true);
}
js.JsObject _createRegistry(TestabilityRegistry registry) {
var object = new js.JsObject(js.context['Object']);
object['getAngularTestability'] =
_jsify((Element elem, bool findInAncestors) {
var testability = registry.findTestabilityInTree(elem, findInAncestors);
return testability == null
? null
: _jsify(new PublicTestability(testability));
});
var testability = registry.findTestabilityInTree(elem, findInAncestors);
return testability == null
? null
: _jsify(new PublicTestability(testability));
});
object['getAllAngularTestabilities'] = _jsify(() {
var publicTestabilities = registry
.getAllTestabilities()
@ -146,4 +162,4 @@ class BrowserGetTestability implements GetTestability {
});
return object;
}
}
}

View File

@ -1,10 +1,17 @@
import {Map, MapWrapper, ListWrapper} from 'angular2/src/facade/collection';
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 {
Injectable,
TestabilityRegistry,
Testability,
GetTestability,
setTestabilityGetter
} from 'angular2/src/core/testability/testability';
import {global} from 'angular2/src/facade/lang';
} from 'angular2/core';
class PublicTestability {
/** @internal */
@ -29,18 +36,34 @@ export class BrowserGetTestability implements GetTestability {
static init() { setTestabilityGetter(new BrowserGetTestability()); }
addToWindow(registry: TestabilityRegistry): void {
global.getAngularTestability = function(elem: Element,
findInAncestors: boolean = true): PublicTestability {
global.getAngularTestability = (elem: any, findInAncestors: boolean = true) => {
var testability = registry.findTestabilityInTree(elem, findInAncestors);
if (testability == null) {
throw new Error('Could not find testability for element.');
}
return new PublicTestability(testability);
};
global.getAllAngularTestabilities = function(): PublicTestability[] {
global.getAllAngularTestabilities = () => {
var testabilities = registry.getAllTestabilities();
return testabilities.map((testability) => { return new PublicTestability(testability); });
};
}
findTestabilityInTree(registry: TestabilityRegistry, elem: any,
findInAncestors: boolean): Testability {
if (elem == null) {
return null;
}
var t = registry.getTestability(elem);
if (isPresent(t)) {
return t;
} else if (!findInAncestors) {
return null;
}
if (DOM.isShadowRoot(elem)) {
return this.findTestabilityInTree(registry, DOM.getHost(elem), true);
}
return this.findTestabilityInTree(registry, DOM.parentElement(elem), true);
}
}

View File

@ -10,7 +10,8 @@ import {
Reflector,
reflector,
APPLICATION_COMMON_PROVIDERS,
PLATFORM_COMMON_PROVIDERS
PLATFORM_COMMON_PROVIDERS,
EVENT_MANAGER_PLUGINS
} from "angular2/core";
import {COMMON_DIRECTIVES, COMMON_PIPES, FORM_PROVIDERS} from "angular2/common";
import {Renderer} from 'angular2/render';
@ -18,21 +19,28 @@ import {Testability} from 'angular2/src/core/testability/testability';
// TODO change these imports once dom_adapter is moved out of core
import {DOM} from 'angular2/src/core/dom/dom_adapter';
import {
DomEventsPlugin,
EVENT_MANAGER_PLUGINS
} from 'angular2/src/core/render/dom/events/event_manager';
import {KeyEventsPlugin} from 'angular2/src/core/render/dom/events/key_events';
import {HammerGesturesPlugin} from 'angular2/src/core/render/dom/events/hammer_gestures';
import {DOCUMENT} from 'angular2/src/core/render/dom/dom_tokens';
import {DomRenderer, DomRenderer_} from 'angular2/src/core/render/dom/dom_renderer';
import {DomSharedStylesHost} from 'angular2/src/core/render/dom/shared_styles_host';
import {SharedStylesHost} from "angular2/src/core/render/dom/shared_styles_host";
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';
import {DOCUMENT} from 'angular2/src/platform/dom/dom_tokens';
import {DomRenderer, DomRenderer_} from 'angular2/src/platform/dom/dom_renderer';
import {DomSharedStylesHost} from 'angular2/src/platform/dom/shared_styles_host';
import {SharedStylesHost} from "angular2/src/platform/dom/shared_styles_host";
import {BrowserDetails} from "angular2/src/animate/browser_details";
import {AnimationBuilder} from "angular2/src/animate/animation_builder";
import {BrowserDomAdapter} from 'angular2/src/core/dom/browser_adapter';
import {BrowserGetTestability} from 'angular2/src/core/testability/browser_testability';
import {BrowserDomAdapter} from './browser/browser_adapter';
import {BrowserGetTestability} from 'angular2/src/platform/browser/testability';
import {wtfInit} from 'angular2/src/core/profile/wtf_init';
export {DOCUMENT} from 'angular2/src/platform/dom/dom_tokens';
export {Title} from 'angular2/src/platform/browser/title';
export {
// DebugElementViewListener,
ELEMENT_PROBE_PROVIDERS,
ELEMENT_PROBE_BINDINGS,
inspectNativeElement
} from 'angular2/src/platform/browser/debug/debug_element_view_listener';
export {By} from 'angular2/src/platform/browser/debug/by';
export {BrowserDomAdapter} from './browser/browser_adapter';
export const BROWSER_PROVIDERS: Array<any /*Type | Provider | any[]*/> =
CONST_EXPR([PLATFORM_COMMON_PROVIDERS]);

View File

@ -1,5 +1,6 @@
import {Inject, Injectable, OpaqueToken} from 'angular2/src/core/di';
import {AnimationBuilder} from 'angular2/src/animate/animation_builder';
import {
isPresent,
isBlank,
@ -8,14 +9,10 @@ import {
stringify,
StringWrapper
} from 'angular2/src/facade/lang';
import {BaseException, WrappedException} from 'angular2/src/facade/exceptions';
import {DOM} from 'angular2/src/core/dom/dom_adapter';
import {EventManager} from './events/event_manager';
import {DomSharedStylesHost} from './shared_styles_host';
import {WtfScopeFn, wtfLeave, wtfCreateScope} from '../../profile/profile';
import {WtfScopeFn, wtfLeave, wtfCreateScope} from 'angular2/src/core/profile/profile';
import {
Renderer,
@ -26,15 +23,28 @@ import {
RenderViewWithFragments,
RenderTemplateCmd,
RenderEventDispatcher,
RenderComponentTemplate
} from '../api';
RenderComponentTemplate,
EventManager
} from 'angular2/core';
import {DOCUMENT} from './dom_tokens';
import {createRenderView, NodeFactory, encapsulateStyles} from '../view_factory';
import {DefaultRenderView, DefaultRenderFragmentRef, DefaultProtoViewRef} from '../view';
import {
createRenderView,
NodeFactory,
encapsulateStyles
} from 'angular2/src/core/render/view_factory';
import {
DefaultRenderView,
DefaultRenderFragmentRef,
DefaultProtoViewRef
} from 'angular2/src/core/render/view';
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';
// TODO(tbosch): solve SVG properly once https://github.com/angular/angular/issues/4417 is done
const XLINK_NAMESPACE = 'http://www.w3.org/1999/xlink';
const SVG_NAMESPACE = 'http://www.w3.org/2000/svg';

View File

@ -0,0 +1,25 @@
import {DOM} from 'angular2/src/core/dom/dom_adapter';
import {Injectable, EventManagerPlugin, EventManager} from 'angular2/core';
@Injectable()
export class DomEventsPlugin extends EventManagerPlugin {
manager: EventManager;
// This plugin should come last in the list of plugins, because it accepts all
// events.
supports(eventName: string): boolean { return true; }
addEventListener(element: HTMLElement, eventName: string, handler: Function) {
var zone = this.manager.getZone();
var outsideHandler = (event) => zone.run(() => handler(event));
this.manager.getZone().runOutsideAngular(() => { DOM.on(element, eventName, outsideHandler); });
}
addGlobalEventListener(target: string, eventName: string, handler: Function): Function {
var element = DOM.getGlobalEventTarget(target);
var zone = this.manager.getZone();
var outsideHandler = (event) => zone.run(() => handler(event));
return this.manager.getZone().runOutsideAngular(
() => { return DOM.onAndCancel(element, eventName, outsideHandler); });
}
}

View File

@ -1,4 +1,4 @@
import {EventManagerPlugin} from './event_manager';
import {EventManagerPlugin} from 'angular2/core';
import {StringMapWrapper} from 'angular2/src/facade/collection';
var _eventNames = {

View File

@ -7,7 +7,7 @@ import {
NumberWrapper
} from 'angular2/src/facade/lang';
import {StringMapWrapper, ListWrapper} from 'angular2/src/facade/collection';
import {EventManagerPlugin} from './event_manager';
import {EventManagerPlugin} from 'angular2/core';
import {NgZone} from 'angular2/src/core/zone/ng_zone';
import {Injectable} from 'angular2/src/core/di';

View File

@ -0,0 +1,15 @@
import {StringWrapper} from 'angular2/src/facade/lang';
var CAMEL_CASE_REGEXP = /([A-Z])/g;
var DASH_CASE_REGEXP = /-([a-z])/g;
export function camelCaseToDashCase(input: string): string {
return StringWrapper.replaceAllMapped(input, CAMEL_CASE_REGEXP,
(m) => { return '-' + m[1].toLowerCase(); });
}
export function dashCaseToCamelCase(input: string): string {
return StringWrapper.replaceAllMapped(input, DASH_CASE_REGEXP,
(m) => { return m[1].toUpperCase(); });
}

View File

@ -3,7 +3,7 @@ library angular2.dom.abstractHtmlAdapter;
import 'package:html/parser.dart' as parser;
import 'package:html/dom.dart';
import 'dom_adapter.dart';
import 'package:angular2/core.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 'dom_adapter.dart';
import 'package:angular2/core.dart' show setRootDomAdapter;
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 './dom_adapter';
import {DomAdapter, setRootDomAdapter} from 'angular2/core';
import {
isPresent,
isBlank,

View File

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

View File

@ -1,4 +1,4 @@
import {BrowserDomAdapter} from 'angular2/src/core/dom/browser_adapter';
import {BrowserDomAdapter} from 'angular2/src/platform/browser/browser_adapter';
import {document, window} from 'angular2/src/facade/browser';
import {NumberWrapper, isBlank} from 'angular2/src/facade/lang';
import {BaseException, WrappedException} from 'angular2/src/facade/exceptions';

View File

@ -17,7 +17,7 @@ import {
import {el} from './utils';
import {DOCUMENT} from 'angular2/src/core/render/render';
import {DOCUMENT} from 'angular2/src/platform/dom/dom_tokens';
import {DOM} from 'angular2/src/core/dom/dom_adapter';
import {DebugElement, DebugElement_} from 'angular2/src/core/debug/debug_element';

View File

@ -21,12 +21,7 @@ import {NgZone} from 'angular2/src/core/zone/ng_zone';
import {DOM} from 'angular2/src/core/dom/dom_adapter';
import {
EventManager,
DomEventsPlugin,
EVENT_MANAGER_PLUGINS
} from 'angular2/src/core/render/dom/events/event_manager';
import {EventManager, EVENT_MANAGER_PLUGINS} from 'angular2/core';
import {MockDirectiveResolver} from 'angular2/src/mock/directive_resolver_mock';
import {MockViewResolver} from 'angular2/src/mock/view_resolver_mock';
import {MockLocationStrategy} from 'angular2/src/mock/mock_location_strategy';
@ -36,7 +31,9 @@ import {MockNgZone} from 'angular2/src/mock/ng_zone_mock';
import {TestComponentBuilder} from './test_component_builder';
import {Injector} from 'angular2/src/core/di';
import {ELEMENT_PROBE_PROVIDERS} from 'angular2/src/core/debug';
import {
ELEMENT_PROBE_PROVIDERS
} from 'angular2/src/platform/browser/debug/debug_element_view_listener';
import {ListWrapper} from 'angular2/src/facade/collection';
import {FunctionWrapper, Type} from 'angular2/src/facade/lang';
@ -45,17 +42,18 @@ import {AppViewPool, APP_VIEW_POOL_CAPACITY} from 'angular2/src/core/linker/view
import {AppViewManager} from 'angular2/src/core/linker/view_manager';
import {AppViewManagerUtils} from 'angular2/src/core/linker/view_manager_utils';
import {Renderer} from 'angular2/src/core/render/api';
import {
DomRenderer,
DOCUMENT,
SharedStylesHost,
DomSharedStylesHost
} from 'angular2/src/core/render/render';
import {DOCUMENT} from 'angular2/src/platform/dom/dom_tokens';
import {DomRenderer} from 'angular2/src/platform/dom/dom_renderer';
import {DomSharedStylesHost} from 'angular2/src/platform/dom/shared_styles_host';
import {SharedStylesHost} from 'angular2/src/platform/dom/shared_styles_host';
import {DomEventsPlugin} from 'angular2/src/platform/dom/events/dom_events';
import {APP_ID} from 'angular2/src/core/application_tokens';
import {Serializer} from "angular2/src/web_workers/shared/serializer";
import {Log} from './utils';
import {COMPILER_PROVIDERS} from 'angular2/src/compiler/compiler';
import {DomRenderer_} from "angular2/src/core/render/dom/dom_renderer";
import {DomRenderer_} from "angular2/src/platform/dom/dom_renderer";
import {DynamicComponentLoader_} from "angular2/src/core/linker/dynamic_component_loader";
import {AppViewManager_} from "angular2/src/core/linker/view_manager";

View File

@ -5,26 +5,21 @@ import {AnimationBuilder} from 'angular2/src/animate/animation_builder';
import {BrowserDetails} from 'angular2/src/animate/browser_details';
import {Reflector, reflector} from 'angular2/src/core/reflection/reflection';
import {Parser, Lexer} from 'angular2/src/core/change_detection/change_detection';
import {
EventManager,
DomEventsPlugin,
EVENT_MANAGER_PLUGINS
} from 'angular2/src/core/render/dom/events/event_manager';
import {EventManager, EVENT_MANAGER_PLUGINS} from 'angular2/core';
import {ProtoViewFactory} from 'angular2/src/core/linker/proto_view_factory';
import {BrowserDomAdapter} from 'angular2/src/core/dom/browser_adapter';
import {KeyEventsPlugin} from 'angular2/src/core/render/dom/events/key_events';
import {HammerGesturesPlugin} from 'angular2/src/core/render/dom/events/hammer_gestures';
import {BrowserDomAdapter} from 'angular2/src/platform/browser/browser_adapter';
import {KeyEventsPlugin} from 'angular2/src/platform/dom/events/key_events';
import {HammerGesturesPlugin} from 'angular2/src/platform/dom/events/hammer_gestures';
import {AppViewPool, APP_VIEW_POOL_CAPACITY} from 'angular2/src/core/linker/view_pool';
import {Renderer} from 'angular2/src/core/render/api';
import {AppRootUrl} from 'angular2/src/compiler/app_root_url';
import {DomRenderer, DomRenderer_, DOCUMENT} from 'angular2/src/core/render/render';
import {DOCUMENT} from 'angular2/src/platform/dom/dom_tokens';
import {DomRenderer, DomRenderer_} from 'angular2/src/platform/dom/dom_renderer';
import {DomEventsPlugin} from 'angular2/src/platform/dom/events/dom_events';
import {APP_ID_RANDOM_PROVIDER} from 'angular2/src/core/application_tokens';
import {ElementSchemaRegistry} from 'angular2/src/compiler/schema/element_schema_registry';
import {DomElementSchemaRegistry} from 'angular2/src/compiler/schema/dom_element_schema_registry';
import {
SharedStylesHost,
DomSharedStylesHost
} from 'angular2/src/core/render/dom/shared_styles_host';
import {SharedStylesHost, DomSharedStylesHost} from 'angular2/src/platform/dom/shared_styles_host';
import {DOM} from 'angular2/src/core/dom/dom_adapter';
import {NgZone} from 'angular2/src/core/zone/ng_zone';
import {AppViewManager, AppViewManager_} from 'angular2/src/core/linker/view_manager';

View File

@ -9,7 +9,7 @@ import {createInjector} from "./di_bindings";
import {MessageBus, MessageBusSink} from "angular2/src/web_workers/shared/message_bus";
import {createNgZone} from 'angular2/src/core/application_ref';
import {Injectable} from 'angular2/src/core/di';
import {BrowserDomAdapter} from 'angular2/src/core/dom/browser_adapter';
import {BrowserDomAdapter} from 'angular2/src/platform/browser/browser_adapter';
import {wtfInit} from 'angular2/src/core/profile/wtf_init';
import {WebWorkerSetup} from 'angular2/src/web_workers/ui/setup';
import {MessageBasedRenderer} from 'angular2/src/web_workers/ui/renderer';

View File

@ -10,7 +10,7 @@ import "package:angular2/src/core/linker/dynamic_component_loader.dart"
import "dart:isolate";
import "dart:async";
import 'dart:core';
import 'package:angular2/src/core/dom/webworker_adapter.dart';
import 'package:angular2/src/platform/server/webworker_adapter.dart';
/**
* Bootstrapping a Webworker Application

View File

@ -10,7 +10,7 @@ import {Promise} from 'angular2/src/facade/async';
import {bootstrapWebWorkerCommon} from "angular2/src/web_workers/worker/application_common";
import {ComponentRef} from "angular2/src/core/linker/dynamic_component_loader";
export * from "angular2/src/web_workers/shared/message_bus";
import {Parse5DomAdapter} from 'angular2/src/core/dom/parse5_adapter';
import {Parse5DomAdapter} from 'angular2/src/platform/server/parse5_adapter';
// TODO(jteplitz602) remove this and compile with lib.webworker.d.ts (#3492)
interface PostMessageInterface {

View File

@ -36,7 +36,7 @@ import {
forwardRef,
Validator
} from 'angular2/core';
import {By} from 'angular2/src/core/debug';
import {By} from 'angular2/platform/browser';
import {ListWrapper} from 'angular2/src/facade/collection';
import {ObservableWrapper} from 'angular2/src/facade/async';
import {CONST_EXPR} from 'angular2/src/facade/lang';

View File

@ -19,7 +19,8 @@ import {DOM} from 'angular2/src/core/dom/dom_adapter';
import {PromiseWrapper, EventEmitter, ObservableWrapper} from 'angular2/src/facade/async';
import {Injectable, NgFor, NgIf} from 'angular2/core';
import {By, Scope} from 'angular2/src/core/debug';
import {Scope} from 'angular2/core';
import {By} from 'angular2/platform/browser';
import {
Directive,

View File

@ -2,7 +2,7 @@ library angular2.dom.html5lib_adapter.test;
import 'package:guinness/guinness.dart';
import 'package:unittest/unittest.dart' hide expect;
import 'package:angular2/src/core/dom/html_adapter.dart';
import 'package:angular2/src/platform/server/html_adapter.dart';
// A smoke-test of the adapter. It is primarily tested by the compiler.
main() {

View File

@ -24,7 +24,7 @@ import {
View
} from 'angular2/core';
import {Type} from 'angular2/src/facade/lang';
import {asNativeElements} from 'angular2/src/core/debug';
import {asNativeElements} from 'angular2/core';
export function main() {
describe("forwardRef integration", function() {

View File

@ -17,12 +17,12 @@ import {
} from 'angular2/testing_internal';
import {OnDestroy} from 'angular2/lifecycle_hooks';
import {Injector, NgIf} from 'angular2/core';
import {inspectElement, By} from 'angular2/src/core/debug';
import {Injector, NgIf, inspectElement} from 'angular2/core';
import {By} from 'angular2/platform/browser';
import {Component, View, ViewMetadata} from 'angular2/src/core/metadata';
import {DynamicComponentLoader} from 'angular2/src/core/linker/dynamic_component_loader';
import {ElementRef} from 'angular2/src/core/linker/element_ref';
import {DOCUMENT} from 'angular2/src/core/render/render';
import {DOCUMENT} from 'angular2/src/platform/dom/dom_tokens';
import {DOM} from 'angular2/src/core/dom/dom_adapter';
import {ComponentFixture_} from "angular2/src/testing/test_component_builder";

View File

@ -3,7 +3,7 @@ library angular2.test.di.integration_dart_spec;
import 'package:angular2/angular2.dart';
import 'package:angular2/core.dart';
import 'package:angular2/src/core/debug.dart';
import 'package:angular2/src/core/debug/debug_element.dart';
import 'package:angular2/testing_internal.dart';
import 'package:observe/observe.dart';
import 'package:angular2/src/core/change_detection/differs/default_iterable_differ.dart';

View File

@ -91,7 +91,7 @@ import {Compiler} from 'angular2/src/core/linker/compiler';
import {ElementRef} from 'angular2/src/core/linker/element_ref';
import {TemplateRef} from 'angular2/src/core/linker/template_ref';
import {DomRenderer} from 'angular2/src/core/render/dom/dom_renderer';
import {DomRenderer} from 'angular2/src/platform/dom/dom_renderer';
import {IS_DART} from 'angular2/src/facade/lang';
const ANCHOR_ELEMENT = CONST_EXPR(new OpaqueToken('AnchorElement'));

View File

@ -9,7 +9,7 @@ import {
expect,
iit,
inject,
beforeEachBindings,
beforeEachProviders,
it,
xit,
containsRegexp,
@ -36,11 +36,11 @@ import {
ViewEncapsulation,
ViewMetadata
} from 'angular2/core';
import {By} from 'angular2/src/core/debug';
import {By} from 'angular2/platform/browser';
export function main() {
describe('projection', () => {
beforeEachBindings(() => [provide(AppViewListener, {useClass: AppViewListener})]);
beforeEachProviders(() => [provide(AppViewListener, {useClass: AppViewListener})]);
it('should support simple components',
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {

View File

@ -37,9 +37,8 @@ import {
AfterViewChecked
} from 'angular2/core';
import {asNativeElements} from 'angular2/src/core/debug';
import {BrowserDomAdapter} from 'angular2/src/core/dom/browser_adapter';
import {asNativeElements} from 'angular2/core';
import {BrowserDomAdapter} from 'angular2/src/platform/browser/browser_adapter';
export function main() {
BrowserDomAdapter.makeCurrent();

View File

@ -42,7 +42,7 @@ import {
import {DirectiveResolver} from 'angular2/src/core/linker/directive_resolver';
import {Component} from 'angular2/src/core/metadata';
import {AppViewManagerUtils} from 'angular2/src/core/linker/view_manager_utils';
import {RenderViewWithFragments} from 'angular2/src/core/render/render';
import {RenderViewWithFragments} from 'angular2/render';
export function main() {
// TODO(tbosch): add more tests here!

View File

@ -9,11 +9,8 @@ import {
beforeEach,
el
} from 'angular2/testing_internal';
import {
EventManager,
EventManagerPlugin,
DomEventsPlugin
} from 'angular2/src/core/render/dom/events/event_manager';
import {EventManager, EventManagerPlugin} from 'angular2/core';
import {DomEventsPlugin} from 'angular2/src/platform/dom/events/dom_events';
import {NgZone} from 'angular2/src/core/zone/ng_zone';
import {ListWrapper, Map, MapWrapper} from 'angular2/src/facade/collection';
import {DOM} from 'angular2/src/core/dom/dom_adapter';

View File

@ -9,7 +9,7 @@ import {
beforeEach,
el
} from 'angular2/testing_internal';
import {KeyEventsPlugin} from 'angular2/src/core/render/dom/events/key_events';
import {KeyEventsPlugin} from 'angular2/src/platform/dom/events/key_events';
export function main() {
describe('KeyEvents', () => {

View File

@ -17,7 +17,7 @@ import {
} from 'angular2/testing_internal';
import {DOM} from 'angular2/src/core/dom/dom_adapter';
import {DomSharedStylesHost} from 'angular2/src/core/render/dom/shared_styles_host';
import {DomSharedStylesHost} from 'angular2/src/platform/dom/shared_styles_host';
export function main() {
describe('DomSharedStylesHost', () => {

View File

@ -16,7 +16,7 @@ import {ApplicationRef} from 'angular2/src/core/application_ref';
import {Component, Directive, View, OnDestroy, platform} from 'angular2/core';
import {BROWSER_PROVIDERS, BROWSER_APP_PROVIDERS} from 'angular2/platform/browser';
import {DOM} from 'angular2/src/core/dom/dom_adapter';
import {DOCUMENT} from 'angular2/render';
import {DOCUMENT} from 'angular2/src/platform/dom/dom_tokens';
import {PromiseWrapper} from 'angular2/src/facade/async';
import {provide, Inject, Injector} from 'angular2/core';
import {ExceptionHandler} from 'angular2/src/facade/exceptions';

View File

@ -8,7 +8,7 @@ import {
expect,
iit,
inject,
beforeEachBindings,
beforeEachProviders,
it,
xit,
TestComponentBuilder,
@ -16,7 +16,7 @@ import {
import {global} from 'angular2/src/facade/lang';
import {APP_VIEW_POOL_CAPACITY} from 'angular2/src/core/linker/view_pool';
import {provide, Component, Directive, Injectable, View} from 'angular2/core';
import {inspectNativeElement} from 'angular2/src/core/debug';
import {inspectNativeElement} from 'angular2/platform/browser';
import {IS_DART} from 'angular2/src/facade/lang';
@Component({selector: 'my-comp'})
@ -28,7 +28,7 @@ class MyComp {
export function main() {
describe('element probe', function() {
beforeEachBindings(() => [provide(APP_VIEW_POOL_CAPACITY, {useValue: 0})]);
beforeEachProviders(() => [provide(APP_VIEW_POOL_CAPACITY, {useValue: 0})]);
it('should return a TestElement from a dom element',
inject([TestComponentBuilder, AsyncTestCompleter], (tcb: TestComponentBuilder, async) => {

View File

@ -9,11 +9,11 @@ import {
expect,
SpyObject
} from 'angular2/testing_internal';
import {SpyElementRef, SpyDomAdapter} from '../spies';
import {SpyElementRef, SpyDomAdapter} from '../../core/spies';
import {DOM, DomAdapter} from 'angular2/src/core/dom/dom_adapter';
import {Ruler, Rectangle} from 'angular2/src/core/services/ruler';
import {Ruler, Rectangle} from 'angular2/src/platform/browser/ruler';
import {createRectangle} from './rectangle_mock';
function assertDimensions(rect: Rectangle, left, right, top, bottom, width, height) {

View File

@ -1,7 +1,6 @@
import {ddescribe, describe, it, iit, xit, expect, afterEach} from 'angular2/testing_internal';
import {DOM} from 'angular2/src/core/dom/dom_adapter';
import {Title} from 'angular2/src/core/services/title';
import {Title} from 'angular2/platform/browser';
export function main() {
describe('title service', () => {

View File

@ -16,8 +16,8 @@ import {PromiseWrapper} from 'angular2/src/facade/async';
export function main() {
describe('XHRImpl', () => {
var xhr: XHRImpl;
var url200 = '/base/modules/angular2/test/core/services/static_assets/200.html';
var url404 = '/base/modules/angular2/test/core/services/static_assets/404.html';
var url200 = '/base/modules/angular2/test/platform/browser/static_assets/200.html';
var url404 = '/base/modules/angular2/test/platform/browser/static_assets/404.html';
beforeEach(() => { xhr = new XHRImpl(); });

View File

@ -129,6 +129,121 @@ var NG_ALL = [
'Binding.toValue',
'BROWSER_APP_PROVIDERS:js',
'BROWSER_PROVIDERS:js',
'BrowserDomAdapter:js',
'BrowserDomAdapter#makeCurrent():js',
'BrowserDomAdapter.addClass():js',
'BrowserDomAdapter.adoptNode():js',
'BrowserDomAdapter.appendChild():js',
'BrowserDomAdapter.attrToPropMap:js',
'BrowserDomAdapter.attributeMap():js',
'BrowserDomAdapter.cancelAnimationFrame():js',
'BrowserDomAdapter.childNodes():js',
'BrowserDomAdapter.childNodesAsList():js',
'BrowserDomAdapter.classList():js',
'BrowserDomAdapter.clearNodes():js',
'BrowserDomAdapter.clone():js',
'BrowserDomAdapter.content():js',
'BrowserDomAdapter.createComment():js',
'BrowserDomAdapter.createElement():js',
'BrowserDomAdapter.createElementNS():js',
'BrowserDomAdapter.createEvent():js',
'BrowserDomAdapter.createHtmlDocument():js',
'BrowserDomAdapter.createMouseEvent():js',
'BrowserDomAdapter.createScriptTag():js',
'BrowserDomAdapter.createShadowRoot():js',
'BrowserDomAdapter.createStyleElement():js',
'BrowserDomAdapter.createTemplate():js',
'BrowserDomAdapter.createTextNode():js',
'BrowserDomAdapter.defaultDoc():js',
'BrowserDomAdapter.dispatchEvent():js',
'BrowserDomAdapter.elementMatches():js',
'BrowserDomAdapter.firstChild():js',
'BrowserDomAdapter.getAnimationPrefix():js',
'BrowserDomAdapter.getAttribute():js',
'BrowserDomAdapter.getBaseHref():js',
'BrowserDomAdapter.getBoundingClientRect():js',
'BrowserDomAdapter.getChecked():js',
'BrowserDomAdapter.getComputedStyle():js',
'BrowserDomAdapter.getData():js',
'BrowserDomAdapter.getDistributedNodes():js',
'BrowserDomAdapter.getElementsByClassName():js',
'BrowserDomAdapter.getElementsByTagName():js',
'BrowserDomAdapter.getEventKey():js',
'BrowserDomAdapter.getGlobalEventTarget():js',
'BrowserDomAdapter.getHistory():js',
'BrowserDomAdapter.getHost():js',
'BrowserDomAdapter.getHref():js',
'BrowserDomAdapter.getInnerHTML():js',
'BrowserDomAdapter.getLocation():js',
'BrowserDomAdapter.getOuterHTML():js',
'BrowserDomAdapter.getProperty():js',
'BrowserDomAdapter.getShadowRoot():js',
'BrowserDomAdapter.getStyle():js',
'BrowserDomAdapter.getText():js',
'BrowserDomAdapter.getTitle():js',
'BrowserDomAdapter.getTransitionEnd():js',
'BrowserDomAdapter.getUserAgent():js',
'BrowserDomAdapter.getValue():js',
'BrowserDomAdapter.getXHR():js',
'BrowserDomAdapter.hasAttribute():js',
'BrowserDomAdapter.hasClass():js',
'BrowserDomAdapter.hasProperty():js',
'BrowserDomAdapter.hasShadowRoot():js',
'BrowserDomAdapter.importIntoDoc():js',
'BrowserDomAdapter.insertAfter():js',
'BrowserDomAdapter.insertAllBefore():js',
'BrowserDomAdapter.insertBefore():js',
'BrowserDomAdapter.invoke():js',
'BrowserDomAdapter.isCommentNode():js',
'BrowserDomAdapter.isElementNode():js',
'BrowserDomAdapter.isPrevented():js',
'BrowserDomAdapter.isShadowRoot():js',
'BrowserDomAdapter.isTemplateElement():js',
'BrowserDomAdapter.isTextNode():js',
'BrowserDomAdapter.log():js',
'BrowserDomAdapter.logError():js',
'BrowserDomAdapter.logGroup():js',
'BrowserDomAdapter.logGroupEnd():js',
'BrowserDomAdapter.nextSibling():js',
'BrowserDomAdapter.nodeName():js',
'BrowserDomAdapter.nodeValue():js',
'BrowserDomAdapter.on():js',
'BrowserDomAdapter.onAndCancel():js',
'BrowserDomAdapter.parentElement():js',
'BrowserDomAdapter.parse():js',
'BrowserDomAdapter.performanceNow():js',
'BrowserDomAdapter.preventDefault():js',
'BrowserDomAdapter.query():js',
'BrowserDomAdapter.querySelector():js',
'BrowserDomAdapter.querySelectorAll():js',
'BrowserDomAdapter.remove():js',
'BrowserDomAdapter.removeAttribute():js',
'BrowserDomAdapter.removeChild():js',
'BrowserDomAdapter.removeClass():js',
'BrowserDomAdapter.removeStyle():js',
'BrowserDomAdapter.replaceChild():js',
'BrowserDomAdapter.requestAnimationFrame():js',
'BrowserDomAdapter.resetBaseElement():js',
'BrowserDomAdapter.resolveAndSetHref():js',
'BrowserDomAdapter.setAttribute():js',
'BrowserDomAdapter.setAttributeNS():js',
'BrowserDomAdapter.setChecked():js',
'BrowserDomAdapter.setData():js',
'BrowserDomAdapter.setGlobalVar():js',
'BrowserDomAdapter.setInnerHTML():js',
'BrowserDomAdapter.setProperty():js',
'BrowserDomAdapter.setStyle():js',
'BrowserDomAdapter.setText():js',
'BrowserDomAdapter.setTitle():js',
'BrowserDomAdapter.setValue():js',
'BrowserDomAdapter.supportsAnimation():js',
'BrowserDomAdapter.supportsDOMEvents():js',
'BrowserDomAdapter.supportsNativeShadowDOM():js',
'BrowserDomAdapter.tagName():js',
'BrowserDomAdapter.templateAwareRoot():js',
'BrowserDomAdapter.type():js',
'Provider',
'Provider.dependencies',
'Provider.multi',
@ -144,10 +259,10 @@ var NG_ALL = [
'ProviderBuilder.toValue()',
'ProviderBuilder.token',
'ProviderBuilder.token=',
'By#all()',
'By#css()',
'By#directive()',
'By',
'By#all():js',
'By#css():js',
'By#directive():js',
'By:js',
'CORE_DIRECTIVES',
'COMMON_DIRECTIVES',
'PLATFORM_DIRECTIVES:js',
@ -479,14 +594,19 @@ var NG_ALL = [
'DirectiveResolver',
'DirectiveResolver.resolve()',
'DynamicComponentLoader',
'DomAdapter',
'DomAdapter.attrToPropMap:dart',
'DomAdapter.attrToPropMap=:dart',
'setRootDomAdapter()',
'DOM',
/*
Abstract methods
'DynamicComponentLoader.loadAsRoot()',
'DynamicComponentLoader.loadIntoLocation()',
'DynamicComponentLoader.loadNextToLocation()',
*/
'ELEMENT_PROBE_PROVIDERS',
'ELEMENT_PROBE_BINDINGS',
'ELEMENT_PROBE_PROVIDERS:js',
'ELEMENT_PROBE_BINDINGS:js',
'ElementRef',
'ElementRef.boundElementIndex',
'ElementRef.boundElementIndex=',
@ -494,6 +614,17 @@ var NG_ALL = [
'ElementRef.parentView',
'ElementRef.parentView=',
'ElementRef.renderView',
'EVENT_MANAGER_PLUGINS',
'EventManager',
'EventManager.addEventListener()',
'EventManager.addGlobalEventListener()',
'EventManager.getZone()',
'EventManagerPlugin',
'EventManagerPlugin.addEventListener()',
'EventManagerPlugin.addGlobalEventListener()',
'EventManagerPlugin.supports()',
'EventManagerPlugin.manager:dart',
'EventManagerPlugin.manager=:dart',
'ErrorHandlingFn:dart',
'Output',
'Output.bindingPropertyName',
@ -1112,10 +1243,27 @@ var NG_ALL = [
Abstract method
'TemplateRef.hasLocal()',
*/
'Testability',
'Testability.decreasePendingRequestCount()',
'Testability.findBindings()',
'Testability.findProviders()',
'Testability.getPendingRequestCount()',
'Testability.increasePendingRequestCount()',
'Testability.isAngularEventPending()',
'Testability.isStable()',
'Testability.whenStable()',
'TestabilityRegistry',
'TestabilityRegistry.findTestabilityInTree()',
'TestabilityRegistry.getAllTestabilities()',
'TestabilityRegistry.getTestability()',
'TestabilityRegistry.registerApplication()',
'GetTestability:dart',
'setTestabilityGetter()',
'Type:js',
'Title',
'Title.getTitle()',
'Title.setTitle()',
'Title:js',
'Title.getTitle():js',
'Title.setTitle():js',
'TypeLiteral',
'TypeLiteral.type',
'UpperCasePipe',
@ -1242,7 +1390,7 @@ var NG_ALL = [
'createNgZone()',
'forwardRef():js',
'inspectElement()',
'inspectNativeElement()',
'inspectNativeElement():js',
'platform():js',
'resolveForwardRef():js',
'wtfCreateScope():js',
@ -1313,6 +1461,17 @@ var NG_ALL = [
'RenderElementRef.renderView=',
'RenderEventDispatcher:dart',
'RenderNgContentCmd.index',
'RenderComponentTemplate',
'RenderComponentTemplate.commands',
'RenderComponentTemplate.commands=',
'RenderComponentTemplate.encapsulation',
'RenderComponentTemplate.encapsulation=',
'RenderComponentTemplate.id',
'RenderComponentTemplate.id=',
'RenderComponentTemplate.shortId',
'RenderComponentTemplate.shortId=',
'RenderComponentTemplate.styles',
'RenderComponentTemplate.styles=',
'Stream:dart',
'Stream.any():dart',
'Stream.asBroadcastStream():dart',

View File

@ -18,7 +18,7 @@ import {bootstrap} from 'angular2/bootstrap';
import {Component, Directive, View} from 'angular2/src/core/metadata';
import {DOM} from 'angular2/src/core/dom/dom_adapter';
import {provide} from 'angular2/core';
import {DOCUMENT} from 'angular2/src/core/render/render';
import {DOCUMENT} from 'angular2/src/platform/dom/dom_tokens';
import {RouteConfig, Route, Redirect} from 'angular2/src/router/route_config_decorator';
import {PromiseWrapper} from 'angular2/src/facade/async';
import {BaseException, WrappedException} from 'angular2/src/facade/exceptions';

View File

@ -15,7 +15,7 @@ import {bootstrap} from 'angular2/bootstrap';
import {Component, Directive, View} from 'angular2/src/core/metadata';
import {DOM} from 'angular2/src/core/dom/dom_adapter';
import {provide} from 'angular2/core';
import {DOCUMENT} from 'angular2/src/core/render/render';
import {DOCUMENT} from 'angular2/src/platform/dom/dom_tokens';
import {Type} from 'angular2/src/facade/lang';
import {

View File

@ -17,7 +17,7 @@ import {
import {SpyRouter, SpyLocation} from './spies';
import {provide, Component, View} from 'angular2/core';
import {By} from 'angular2/src/core/debug';
import {By} from 'angular2/platform/browser';
import {
Location,

View File

@ -1,6 +1,6 @@
library angular2.test.web_workers.debug_tools.bootstrap;
import 'package:angular2/src/core/dom/html_adapter.dart';
import 'package:angular2/src/platform/server/html_adapter.dart';
import "package:angular2/testing_internal.dart";
import "package:angular2/src/core/reflection/reflection_capabilities.dart";
import "package:angular2/src/core/reflection/reflection.dart";

View File

@ -39,7 +39,7 @@ import {
RenderFragmentRef,
Renderer
} from "angular2/src/core/render/api";
import {DomRenderer, DomRenderer_} from 'angular2/src/core/render/dom/dom_renderer';
import {DomRenderer, DomRenderer_} from 'angular2/src/platform/dom/dom_renderer';
import {DefaultRenderView} from 'angular2/src/core/render/view';
import {
RenderProtoViewRefStore,

View File

@ -8,7 +8,9 @@ export * from 'angular2/src/facade/facade';
// web_worker exports its own
// export * from '../src/core/application';
export * from '../src/core/application_ref';
export * from '../src/core/services';
export * from '../src/platform/browser/ruler';
export * from '../src/platform/browser/title';
export * from '../src/compiler/url_resolver';
export * from '../src/core/linker';
export * from '../src/core/zone';
// Do not export render in web_worker
@ -31,10 +33,10 @@ export {
RenderBeginComponentCmd,
RenderEmbeddedTemplateCmd,
RenderBeginCmd
} from '../src/core/render/render';
} from '../src/core/render/api';
export * from '../src/common/directives';
export * from '../src/common/forms';
export * from '../src/core/debug';
export {DebugElement} from '../src/core/debug/debug_element';
export * from '../src/core/change_detection';
export * from '../profile';

View File

@ -2,7 +2,7 @@ import {
AsyncTestCompleter,
TestComponentBuilder,
beforeEach,
beforeEachBindings,
beforeEachProviders,
ddescribe,
describe,
el,
@ -14,7 +14,8 @@ import {
} from 'angular2/testing_internal';
import {DebugElement} from 'angular2/src/core/debug/debug_element';
import {Component, View, ViewMetadata, UrlResolver, bind, provide} from 'angular2/core';
import {Component, View, ViewMetadata, bind, provide} from 'angular2/core';
import {UrlResolver} from 'angular2/compiler';
import {MdButton, MdAnchor} from 'angular2_material/src/components/button/button';
@ -25,11 +26,10 @@ export function main() {
describe('MdButton', () => {
let builder: TestComponentBuilder;
beforeEachBindings(() => [
beforeEachProviders(() => [
// Need a custom URL resolver for ng-material template files in order for them to work
// with both JS and Dart output.
bind(UrlResolver)
.toValue(new TestUrlResolver()),
provide(UrlResolver, {useValue: new TestUrlResolver()})
]);
beforeEach(inject([TestComponentBuilder], (tcb) => { builder = tcb; }));

View File

@ -1,6 +1,6 @@
library ng_material.test_url_resolver;
import 'package:angular2/src/core/dom/browser_adapter.dart';
import 'package:angular2/src/platform/browser/browser_adapter.dart';
import 'package:angular2/src/compiler/url_resolver.dart';
void commonDemoSetup() {

View File

@ -1,7 +1,7 @@
import {reflector} from 'angular2/src/core/reflection/reflection';
import {isPresent} from 'angular2/src/facade/lang';
import {getIntParameter, bindAction, microBenchmark} from 'angular2/src/testing/benchmark_util';
import {BrowserDomAdapter} from 'angular2/src/core/dom/browser_adapter';
import {BrowserDomAdapter} from 'angular2/src/platform/browser/browser_adapter';
import {
Lexer,

View File

@ -1,5 +1,5 @@
import {bootstrap} from 'angular2/bootstrap';
import {BrowserDomAdapter} from 'angular2/src/core/dom/browser_adapter';
import {BrowserDomAdapter} from 'angular2/src/platform/browser/browser_adapter';
import {DOM} from 'angular2/src/core/dom/dom_adapter';
import {PromiseWrapper} from 'angular2/src/facade/async';
import {ListWrapper, Map, MapWrapper} from 'angular2/src/facade/collection';

View File

@ -2,7 +2,7 @@ import {SelectorMatcher} from "angular2/src/compiler/selector";
import {CssSelector} from "angular2/src/compiler/selector";
import {StringWrapper, Math} from 'angular2/src/facade/lang';
import {getIntParameter, bindAction} from 'angular2/src/testing/benchmark_util';
import {BrowserDomAdapter} from 'angular2/src/core/dom/browser_adapter';
import {BrowserDomAdapter} from 'angular2/src/platform/browser/browser_adapter';
export function main() {
BrowserDomAdapter.makeCurrent();

View File

@ -2,7 +2,7 @@ import {Injectable, Injector, Key, bind, provide} from "angular2/core";
import {reflector} from 'angular2/src/core/reflection/reflection';
import {ReflectionCapabilities} from 'angular2/src/core/reflection/reflection_capabilities';
import {getIntParameter, bindAction, microBenchmark} from 'angular2/src/testing/benchmark_util';
import {BrowserDomAdapter} from 'angular2/src/core/dom/browser_adapter';
import {BrowserDomAdapter} from 'angular2/src/platform/browser/browser_adapter';
var count = 0;

View File

@ -3,7 +3,7 @@ import {ReflectionCapabilities} from 'angular2/src/core/reflection/reflection_ca
import {Injectable, Injector} from 'angular2/core';
import {ProtoElementInjector, DirectiveProvider} from 'angular2/src/core/linker/element_injector';
import {getIntParameter, bindAction, microBenchmark} from 'angular2/src/testing/benchmark_util';
import {BrowserDomAdapter} from 'angular2/src/core/dom/browser_adapter';
import {BrowserDomAdapter} from 'angular2/src/platform/browser/browser_adapter';
var count = 0;

View File

@ -20,7 +20,7 @@ import {
NgSwitchDefault
} from 'angular2/core';
import {ApplicationRef} from 'angular2/src/core/application_ref';
import {BrowserDomAdapter} from 'angular2/src/core/dom/browser_adapter';
import {BrowserDomAdapter} from 'angular2/src/platform/browser/browser_adapter';
import {APP_VIEW_POOL_CAPACITY} from 'angular2/src/core/linker/view_pool';
import {ListWrapper} from 'angular2/src/facade/collection';

View File

@ -23,7 +23,7 @@ import {
windowProfile,
windowProfileEnd
} from 'angular2/src/testing/benchmark_util';
import {BrowserDomAdapter} from 'angular2/src/core/dom/browser_adapter';
import {BrowserDomAdapter} from 'angular2/src/platform/browser/browser_adapter';
import {APP_VIEW_POOL_CAPACITY} from 'angular2/src/core/linker/view_pool';
function createBindings(): Provider[] {

View File

@ -22,7 +22,7 @@ import {
windowProfile,
windowProfileEnd
} from 'angular2/src/testing/benchmark_util';
import {BrowserDomAdapter} from 'angular2/src/core/dom/browser_adapter';
import {BrowserDomAdapter} from 'angular2/src/platform/browser/browser_adapter';
import {APP_VIEW_POOL_CAPACITY} from 'angular2/src/core/linker/view_pool';
function createProviders(): Provider[] {

View File

@ -1,6 +1,6 @@
import {bootstrap} from 'angular2/bootstrap';
import {Component, View} from 'angular2/core';
import {KeyEventsPlugin} from 'angular2/src/core/render/dom/events/key_events';
import {KeyEventsPlugin} from 'angular2/src/platform/dom/events/key_events';
@Component({selector: 'key-events-app'})
@View({

View File

@ -1,5 +1,6 @@
import {bootstrap} from 'angular2/bootstrap';
import {bind, provide, Component, NgFor, UrlResolver, View, ViewEncapsulation} from 'angular2/core';
import {bind, provide, Component, NgFor, View, ViewEncapsulation} from 'angular2/core';
import {UrlResolver} from 'angular2/compiler';
import {MdButton, MdAnchor} from 'angular2_material/src/components/button/button';
import {commonDemoSetup, DemoUrlResolver} from '../demo_common';

View File

@ -1,13 +1,6 @@
import {bootstrap} from 'angular2/bootstrap';
import {
bind,
provide,
Component,
Directive,
UrlResolver,
View,
ViewEncapsulation
} from 'angular2/core';
import {bind, provide, Component, Directive, View, ViewEncapsulation} from 'angular2/core';
import {UrlResolver} from 'angular2/compiler';
import {MdCheckbox} from 'angular2_material/src/components/checkbox/checkbox';
import {commonDemoSetup, DemoUrlResolver} from '../demo_common';

Some files were not shown because too many files have changed in this diff Show More