Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions modules/angular2/manual_typings/traceur-runtime.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,6 @@
// ES5, because they are redundant with lib.es6.d.ts.
/// <reference path="../typings/es6-promise/es6-promise.d.ts"/>

// es6-promise.d.ts chose a different name for this interface than TS lib.es6.d.ts
// Generic Type Alises are in TS 1.6 (https://github.com/Microsoft/TypeScript/pull/3397)
// So we cannot write:
// declare type PromiseLike = Thenable;
// Until then we use a workaround:
interface PromiseLike<T> extends Thenable<T> {}

// Extend the ES5 standard library with some ES6 features we polyfill at runtime
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you planning to rename this file?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, soon

// by loading es6-shim.js

Expand Down
4 changes: 4 additions & 0 deletions modules/angular2/src/core/dom/browser_adapter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,10 @@ class BrowserDomAdapter extends GenericBrowserDomAdapter {
num performanceNow() {
return window.performance.now();
}

parse(s) {
throw 'not implemented';
}
}

var baseElement = null;
Expand Down
1 change: 1 addition & 0 deletions modules/angular2/src/core/dom/browser_adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ var _chromeNumKeyPadMap = {

/* tslint:disable:requireParameterType */
export class BrowserDomAdapter extends GenericBrowserDomAdapter {
parse(templateHtml: string) { throw new Error("parse not implemented"); }
static makeCurrent() { setRootDomAdapter(new BrowserDomAdapter()); }
hasProperty(element, name: string): boolean { return name in element; }
setProperty(el: /*element*/ any, name: string, value: any) { el[name] = value; }
Expand Down
237 changes: 114 additions & 123 deletions modules/angular2/src/core/dom/dom_adapter.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {isBlank} from 'angular2/src/core/facade/lang';
import {BaseException, WrappedException} from 'angular2/src/core/facade/exceptions';

export var DOM: DomAdapter;

Expand All @@ -9,137 +8,129 @@ export function setRootDomAdapter(adapter: DomAdapter) {
}
}



function _abstract() {
return new BaseException('This method is abstract');
}

/* tslint:disable:requireParameterType */
/**
* Provides DOM operations in an environment-agnostic way.
*/
export class DomAdapter {
hasProperty(element, name: string): boolean { throw _abstract(); }
setProperty(el: Element, name: string, value: any) { throw _abstract(); }
getProperty(el: Element, name: string): any { throw _abstract(); }
invoke(el: Element, methodName: string, args: any[]): any { throw _abstract(); }
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;

logError(error) { throw _abstract(); }
log(error) { throw _abstract(); }
logGroup(error) { throw _abstract(); }
logGroupEnd() { throw _abstract(); }
abstract logError(error);
abstract log(error);
abstract logGroup(error);
abstract logGroupEnd();

/**
* Maps attribute names to their corresponding property names for cases
* where attribute name doesn't match property name.
*/
get attrToPropMap(): StringMap<string, string> { throw _abstract(); }
attrToPropMap: StringMap<string, string>;

parse(templateHtml: string) { throw _abstract(); }
query(selector: string): any { throw _abstract(); }
querySelector(el, selector: string): HTMLElement { throw _abstract(); }
querySelectorAll(el, selector: string): any[] { throw _abstract(); }
on(el, evt, listener) { throw _abstract(); }
onAndCancel(el, evt, listener): Function { throw _abstract(); }
dispatchEvent(el, evt) { throw _abstract(); }
createMouseEvent(eventType): any { throw _abstract(); }
createEvent(eventType: string): any { throw _abstract(); }
preventDefault(evt) { throw _abstract(); }
isPrevented(evt): boolean { throw _abstract(); }
getInnerHTML(el): string { throw _abstract(); }
getOuterHTML(el): string { throw _abstract(); }
nodeName(node): string { throw _abstract(); }
nodeValue(node): string { throw _abstract(); }
type(node): string { throw _abstract(); }
content(node): any { throw _abstract(); }
firstChild(el): Node { throw _abstract(); }
nextSibling(el): Node { throw _abstract(); }
parentElement(el): Node { throw _abstract(); }
childNodes(el): Node[] { throw _abstract(); }
childNodesAsList(el): Node[] { throw _abstract(); }
clearNodes(el) { throw _abstract(); }
appendChild(el, node) { throw _abstract(); }
removeChild(el, node) { throw _abstract(); }
replaceChild(el, newNode, oldNode) { throw _abstract(); }
remove(el): Node { throw _abstract(); }
insertBefore(el, node) { throw _abstract(); }
insertAllBefore(el, nodes) { throw _abstract(); }
insertAfter(el, node) { throw _abstract(); }
setInnerHTML(el, value) { throw _abstract(); }
getText(el): string { throw _abstract(); }
setText(el, value: string) { throw _abstract(); }
getValue(el): string { throw _abstract(); }
setValue(el, value: string) { throw _abstract(); }
getChecked(el): boolean { throw _abstract(); }
setChecked(el, value: boolean) { throw _abstract(); }
createComment(text: string): any { throw _abstract(); }
createTemplate(html): HTMLElement { throw _abstract(); }
createElement(tagName, doc = null): HTMLElement { throw _abstract(); }
createTextNode(text: string, doc = null): Text { throw _abstract(); }
createScriptTag(attrName: string, attrValue: string, doc = null): HTMLElement {
throw _abstract();
}
createStyleElement(css: string, doc = null): HTMLStyleElement { throw _abstract(); }
createShadowRoot(el): any { throw _abstract(); }
getShadowRoot(el): any { throw _abstract(); }
getHost(el): any { throw _abstract(); }
getDistributedNodes(el): Node[] { throw _abstract(); }
clone /*<T extends Node>*/ (node: Node /*T*/): Node /*T*/ { throw _abstract(); }
getElementsByClassName(element, name: string): HTMLElement[] { throw _abstract(); }
getElementsByTagName(element, name: string): HTMLElement[] { throw _abstract(); }
classList(element): any[] { throw _abstract(); }
addClass(element, classname: string) { throw _abstract(); }
removeClass(element, classname: string) { throw _abstract(); }
hasClass(element, classname: string): boolean { throw _abstract(); }
setStyle(element, stylename: string, stylevalue: string) { throw _abstract(); }
removeStyle(element, stylename: string) { throw _abstract(); }
getStyle(element, stylename: string): string { throw _abstract(); }
tagName(element): string { throw _abstract(); }
attributeMap(element): Map<string, string> { throw _abstract(); }
hasAttribute(element, attribute: string): boolean { throw _abstract(); }
getAttribute(element, attribute: string): string { throw _abstract(); }
setAttribute(element, name: string, value: string) { throw _abstract(); }
removeAttribute(element, attribute: string) { throw _abstract(); }
templateAwareRoot(el) { throw _abstract(); }
createHtmlDocument(): HTMLDocument { throw _abstract(); }
defaultDoc(): HTMLDocument { throw _abstract(); }
getBoundingClientRect(el) { throw _abstract(); }
getTitle(): string { throw _abstract(); }
setTitle(newTitle: string) { throw _abstract(); }
elementMatches(n, selector: string): boolean { throw _abstract(); }
isTemplateElement(el: any): boolean { throw _abstract(); }
isTextNode(node): boolean { throw _abstract(); }
isCommentNode(node): boolean { throw _abstract(); }
isElementNode(node): boolean { throw _abstract(); }
hasShadowRoot(node): boolean { throw _abstract(); }
isShadowRoot(node): boolean { throw _abstract(); }
importIntoDoc /*<T extends Node>*/ (node: Node /*T*/): Node /*T*/ { throw _abstract(); }
adoptNode /*<T extends Node>*/ (node: Node /*T*/): Node /*T*/ { throw _abstract(); }
isPageRule(rule): boolean { throw _abstract(); }
isStyleRule(rule): boolean { throw _abstract(); }
isMediaRule(rule): boolean { throw _abstract(); }
isKeyframesRule(rule): boolean { throw _abstract(); }
getHref(element): string { throw _abstract(); }
getEventKey(event): string { throw _abstract(); }
resolveAndSetHref(element, baseUrl: string, href: string) { throw _abstract(); }
cssToRules(css: string): any[] { throw _abstract(); }
supportsDOMEvents(): boolean { throw _abstract(); }
supportsNativeShadowDOM(): boolean { throw _abstract(); }
getGlobalEventTarget(target: string): any { throw _abstract(); }
getHistory(): History { throw _abstract(); }
getLocation(): Location { throw _abstract(); }
getBaseHref(): string { throw _abstract(); }
resetBaseElement(): void { throw _abstract(); }
getUserAgent(): string { throw _abstract(); }
setData(element, name: string, value: string) { throw _abstract(); }
getComputedStyle(element): any { throw _abstract(); }
getData(element, name: string): string { throw _abstract(); }
setGlobalVar(name: string, value: any) { throw _abstract(); }
requestAnimationFrame(callback): number { throw _abstract(); }
cancelAnimationFrame(id) { throw _abstract(); }
performanceNow(): number { throw _abstract(); }
getAnimationPrefix(): string { throw _abstract(); }
getTransitionEnd(): string { throw _abstract(); }
supportsAnimation(): boolean { throw _abstract(); }
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 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 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 isPageRule(rule): boolean;
abstract isStyleRule(rule): boolean;
abstract isMediaRule(rule): boolean;
abstract isKeyframesRule(rule): boolean;
abstract getHref(element): string;
abstract getEventKey(event): string;
abstract resolveAndSetHref(element, baseUrl: string, href: string);
abstract cssToRules(css: string): any[];
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;
}
2 changes: 1 addition & 1 deletion modules/angular2/src/core/dom/generic_browser_adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {DomAdapter} from './dom_adapter';
/**
* Provides DOM operations in any browser environment.
*/
export class GenericBrowserDomAdapter extends DomAdapter {
export abstract class GenericBrowserDomAdapter extends DomAdapter {
private _animationPrefix: string = null;
private _transitionEnd: string = null;
constructor() {
Expand Down
4 changes: 4 additions & 0 deletions modules/angular2/src/core/dom/html_adapter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ class Html5LibDomAdapter implements DomAdapter {
'tabindex': 'tabIndex',
};

set attrToPropMap(value) {
throw 'readonly';
}

@override
getGlobalEventTarget(String target) {
throw 'not implemented';
Expand Down
5 changes: 5 additions & 0 deletions modules/angular2/src/core/dom/parse5_adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,11 @@ export class Parse5DomAdapter extends DomAdapter {
getAnimationPrefix(): string { return ''; }
getTransitionEnd(): string { return 'transitionend'; }
supportsAnimation(): boolean { return true; }

replaceChild(el, newNode, oldNode) { throw new Error('not implemented'); }
parse(templateHtml: string) { throw new Error('not implemented'); }
invoke(el: Element, methodName: string, args: any[]): any { throw new Error('not implemented'); }
getEventKey(event): string { throw new Error('not implemented'); }
}

// TODO: build a proper list, this one is all the keys of a HTMLInputElement
Expand Down
4 changes: 0 additions & 4 deletions modules/angular2/src/core/facade/lang.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@ class CONST {
const CONST();
}

class ABSTRACT {
const ABSTRACT();
}

bool isPresent(obj) => obj != null;
bool isBlank(obj) => obj == null;
bool isString(obj) => obj is String;
Expand Down
4 changes: 0 additions & 4 deletions modules/angular2/src/core/facade/lang.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,6 @@ export function CONST(): ClassDecorator {
return (target) => target;
}

export function ABSTRACT(): ClassDecorator {
return (t) => t;
}

export function isPresent(obj: any): boolean {
return obj !== undefined && obj !== null;
}
Expand Down
7 changes: 5 additions & 2 deletions modules/angular2/src/core/forms/directives/ng_control.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@ import {ControlValueAccessor} from './control_value_accessor';
import {AbstractControlDirective} from './abstract_control_directive';

/**
* An abstract class that all control directive extend.
*
* A base class that all control directive extend.
* It binds a {@link Control} object to a DOM element.
*/
// Cannot currently be abstract because it would contain
// an abstract method in the public API, and we cannot reflect
// on that in Dart due to https://github.com/dart-lang/sdk/issues/18721
// Also we don't have abstract setters, see https://github.com/Microsoft/TypeScript/issues/4669
export class NgControl extends AbstractControlDirective {
name: string = null;
valueAccessor: ControlValueAccessor = null;
Expand Down
2 changes: 1 addition & 1 deletion modules/angular2/src/core/metadata/view.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {ABSTRACT, CONST, Type} from 'angular2/src/core/facade/lang';
import {CONST, Type} from 'angular2/src/core/facade/lang';
import {ViewEncapsulation} from 'angular2/src/core/render/api';

export {ViewEncapsulation} from 'angular2/src/core/render/api';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {ABSTRACT, CONST, Type} from 'angular2/src/core/facade/lang';
import {CONST, Type} from 'angular2/src/core/facade/lang';
import {BaseException, WrappedException} from 'angular2/src/core/facade/exceptions';

export class InvalidPipeArgumentException extends BaseException {
Expand Down
6 changes: 3 additions & 3 deletions modules/angular2/src/http/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ import {URLSearchParams} from './url_search_params';
* The primary purpose of a `ConnectionBackend` is to create new connections to fulfill a given
* {@link Request}.
*/
export class ConnectionBackend {
export abstract class ConnectionBackend {
constructor() {}
createConnection(request: any): Connection { throw new BaseException('Abstract!'); }
abstract createConnection(request: any): Connection;
}

/**
* Abstract class from which real connections are derived.
*/
export class Connection {
export abstract class Connection {
readyState: ReadyStates;
request: Request;
response: EventEmitter; // TODO: generic of <Response>;
Expand Down
2 changes: 2 additions & 0 deletions modules/angular2/src/mock/mock_location_strategy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,6 @@ export class MockLocationStrategy extends LocationStrategy {
this.simulatePopState(nextUrl);
}
}

forward(): void { throw 'not implemented'; }
}
Loading