Skip to content

Commit b4fe590

Browse files
committed
chore(ts): fix TODOs that were pending on 1.6 upgrade
Closes angular#4377
1 parent 8ff65a3 commit b4fe590

25 files changed

+165
-190
lines changed

modules/angular2/manual_typings/traceur-runtime.d.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,6 @@
77
// ES5, because they are redundant with lib.es6.d.ts.
88
/// <reference path="../typings/es6-promise/es6-promise.d.ts"/>
99

10-
// es6-promise.d.ts chose a different name for this interface than TS lib.es6.d.ts
11-
// Generic Type Alises are in TS 1.6 (https://github.com/Microsoft/TypeScript/pull/3397)
12-
// So we cannot write:
13-
// declare type PromiseLike = Thenable;
14-
// Until then we use a workaround:
15-
interface PromiseLike<T> extends Thenable<T> {}
16-
1710
// Extend the ES5 standard library with some ES6 features we polyfill at runtime
1811
// by loading es6-shim.js
1912

modules/angular2/src/core/dom/browser_adapter.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,10 @@ class BrowserDomAdapter extends GenericBrowserDomAdapter {
478478
num performanceNow() {
479479
return window.performance.now();
480480
}
481+
482+
parse(s) {
483+
throw 'not implemented';
484+
}
481485
}
482486

483487
var baseElement = null;

modules/angular2/src/core/dom/browser_adapter.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ var _chromeNumKeyPadMap = {
6161

6262
/* tslint:disable:requireParameterType */
6363
export class BrowserDomAdapter extends GenericBrowserDomAdapter {
64+
parse(templateHtml: string) { throw new Error("parse not implemented"); }
6465
static makeCurrent() { setRootDomAdapter(new BrowserDomAdapter()); }
6566
hasProperty(element, name: string): boolean { return name in element; }
6667
setProperty(el: /*element*/ any, name: string, value: any) { el[name] = value; }
Lines changed: 114 additions & 123 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import {isBlank} from 'angular2/src/core/facade/lang';
2-
import {BaseException, WrappedException} from 'angular2/src/core/facade/exceptions';
32

43
export var DOM: DomAdapter;
54

@@ -9,137 +8,129 @@ export function setRootDomAdapter(adapter: DomAdapter) {
98
}
109
}
1110

12-
13-
14-
function _abstract() {
15-
return new BaseException('This method is abstract');
16-
}
17-
1811
/* tslint:disable:requireParameterType */
1912
/**
2013
* Provides DOM operations in an environment-agnostic way.
2114
*/
22-
export class DomAdapter {
23-
hasProperty(element, name: string): boolean { throw _abstract(); }
24-
setProperty(el: Element, name: string, value: any) { throw _abstract(); }
25-
getProperty(el: Element, name: string): any { throw _abstract(); }
26-
invoke(el: Element, methodName: string, args: any[]): any { throw _abstract(); }
15+
export abstract class DomAdapter {
16+
abstract hasProperty(element, name: string): boolean;
17+
abstract setProperty(el: Element, name: string, value: any);
18+
abstract getProperty(el: Element, name: string): any;
19+
abstract invoke(el: Element, methodName: string, args: any[]): any;
2720

28-
logError(error) { throw _abstract(); }
29-
log(error) { throw _abstract(); }
30-
logGroup(error) { throw _abstract(); }
31-
logGroupEnd() { throw _abstract(); }
21+
abstract logError(error);
22+
abstract log(error);
23+
abstract logGroup(error);
24+
abstract logGroupEnd();
3225

3326
/**
3427
* Maps attribute names to their corresponding property names for cases
3528
* where attribute name doesn't match property name.
3629
*/
37-
get attrToPropMap(): StringMap<string, string> { throw _abstract(); }
30+
attrToPropMap: StringMap<string, string>;
3831

39-
parse(templateHtml: string) { throw _abstract(); }
40-
query(selector: string): any { throw _abstract(); }
41-
querySelector(el, selector: string): HTMLElement { throw _abstract(); }
42-
querySelectorAll(el, selector: string): any[] { throw _abstract(); }
43-
on(el, evt, listener) { throw _abstract(); }
44-
onAndCancel(el, evt, listener): Function { throw _abstract(); }
45-
dispatchEvent(el, evt) { throw _abstract(); }
46-
createMouseEvent(eventType): any { throw _abstract(); }
47-
createEvent(eventType: string): any { throw _abstract(); }
48-
preventDefault(evt) { throw _abstract(); }
49-
isPrevented(evt): boolean { throw _abstract(); }
50-
getInnerHTML(el): string { throw _abstract(); }
51-
getOuterHTML(el): string { throw _abstract(); }
52-
nodeName(node): string { throw _abstract(); }
53-
nodeValue(node): string { throw _abstract(); }
54-
type(node): string { throw _abstract(); }
55-
content(node): any { throw _abstract(); }
56-
firstChild(el): Node { throw _abstract(); }
57-
nextSibling(el): Node { throw _abstract(); }
58-
parentElement(el): Node { throw _abstract(); }
59-
childNodes(el): Node[] { throw _abstract(); }
60-
childNodesAsList(el): Node[] { throw _abstract(); }
61-
clearNodes(el) { throw _abstract(); }
62-
appendChild(el, node) { throw _abstract(); }
63-
removeChild(el, node) { throw _abstract(); }
64-
replaceChild(el, newNode, oldNode) { throw _abstract(); }
65-
remove(el): Node { throw _abstract(); }
66-
insertBefore(el, node) { throw _abstract(); }
67-
insertAllBefore(el, nodes) { throw _abstract(); }
68-
insertAfter(el, node) { throw _abstract(); }
69-
setInnerHTML(el, value) { throw _abstract(); }
70-
getText(el): string { throw _abstract(); }
71-
setText(el, value: string) { throw _abstract(); }
72-
getValue(el): string { throw _abstract(); }
73-
setValue(el, value: string) { throw _abstract(); }
74-
getChecked(el): boolean { throw _abstract(); }
75-
setChecked(el, value: boolean) { throw _abstract(); }
76-
createComment(text: string): any { throw _abstract(); }
77-
createTemplate(html): HTMLElement { throw _abstract(); }
78-
createElement(tagName, doc = null): HTMLElement { throw _abstract(); }
79-
createTextNode(text: string, doc = null): Text { throw _abstract(); }
80-
createScriptTag(attrName: string, attrValue: string, doc = null): HTMLElement {
81-
throw _abstract();
82-
}
83-
createStyleElement(css: string, doc = null): HTMLStyleElement { throw _abstract(); }
84-
createShadowRoot(el): any { throw _abstract(); }
85-
getShadowRoot(el): any { throw _abstract(); }
86-
getHost(el): any { throw _abstract(); }
87-
getDistributedNodes(el): Node[] { throw _abstract(); }
88-
clone /*<T extends Node>*/ (node: Node /*T*/): Node /*T*/ { throw _abstract(); }
89-
getElementsByClassName(element, name: string): HTMLElement[] { throw _abstract(); }
90-
getElementsByTagName(element, name: string): HTMLElement[] { throw _abstract(); }
91-
classList(element): any[] { throw _abstract(); }
92-
addClass(element, classname: string) { throw _abstract(); }
93-
removeClass(element, classname: string) { throw _abstract(); }
94-
hasClass(element, classname: string): boolean { throw _abstract(); }
95-
setStyle(element, stylename: string, stylevalue: string) { throw _abstract(); }
96-
removeStyle(element, stylename: string) { throw _abstract(); }
97-
getStyle(element, stylename: string): string { throw _abstract(); }
98-
tagName(element): string { throw _abstract(); }
99-
attributeMap(element): Map<string, string> { throw _abstract(); }
100-
hasAttribute(element, attribute: string): boolean { throw _abstract(); }
101-
getAttribute(element, attribute: string): string { throw _abstract(); }
102-
setAttribute(element, name: string, value: string) { throw _abstract(); }
103-
removeAttribute(element, attribute: string) { throw _abstract(); }
104-
templateAwareRoot(el) { throw _abstract(); }
105-
createHtmlDocument(): HTMLDocument { throw _abstract(); }
106-
defaultDoc(): HTMLDocument { throw _abstract(); }
107-
getBoundingClientRect(el) { throw _abstract(); }
108-
getTitle(): string { throw _abstract(); }
109-
setTitle(newTitle: string) { throw _abstract(); }
110-
elementMatches(n, selector: string): boolean { throw _abstract(); }
111-
isTemplateElement(el: any): boolean { throw _abstract(); }
112-
isTextNode(node): boolean { throw _abstract(); }
113-
isCommentNode(node): boolean { throw _abstract(); }
114-
isElementNode(node): boolean { throw _abstract(); }
115-
hasShadowRoot(node): boolean { throw _abstract(); }
116-
isShadowRoot(node): boolean { throw _abstract(); }
117-
importIntoDoc /*<T extends Node>*/ (node: Node /*T*/): Node /*T*/ { throw _abstract(); }
118-
adoptNode /*<T extends Node>*/ (node: Node /*T*/): Node /*T*/ { throw _abstract(); }
119-
isPageRule(rule): boolean { throw _abstract(); }
120-
isStyleRule(rule): boolean { throw _abstract(); }
121-
isMediaRule(rule): boolean { throw _abstract(); }
122-
isKeyframesRule(rule): boolean { throw _abstract(); }
123-
getHref(element): string { throw _abstract(); }
124-
getEventKey(event): string { throw _abstract(); }
125-
resolveAndSetHref(element, baseUrl: string, href: string) { throw _abstract(); }
126-
cssToRules(css: string): any[] { throw _abstract(); }
127-
supportsDOMEvents(): boolean { throw _abstract(); }
128-
supportsNativeShadowDOM(): boolean { throw _abstract(); }
129-
getGlobalEventTarget(target: string): any { throw _abstract(); }
130-
getHistory(): History { throw _abstract(); }
131-
getLocation(): Location { throw _abstract(); }
132-
getBaseHref(): string { throw _abstract(); }
133-
resetBaseElement(): void { throw _abstract(); }
134-
getUserAgent(): string { throw _abstract(); }
135-
setData(element, name: string, value: string) { throw _abstract(); }
136-
getComputedStyle(element): any { throw _abstract(); }
137-
getData(element, name: string): string { throw _abstract(); }
138-
setGlobalVar(name: string, value: any) { throw _abstract(); }
139-
requestAnimationFrame(callback): number { throw _abstract(); }
140-
cancelAnimationFrame(id) { throw _abstract(); }
141-
performanceNow(): number { throw _abstract(); }
142-
getAnimationPrefix(): string { throw _abstract(); }
143-
getTransitionEnd(): string { throw _abstract(); }
144-
supportsAnimation(): boolean { throw _abstract(); }
32+
abstract parse(templateHtml: string);
33+
abstract query(selector: string): any;
34+
abstract querySelector(el, selector: string): HTMLElement;
35+
abstract querySelectorAll(el, selector: string): any[];
36+
abstract on(el, evt, listener);
37+
abstract onAndCancel(el, evt, listener): Function;
38+
abstract dispatchEvent(el, evt);
39+
abstract createMouseEvent(eventType): any;
40+
abstract createEvent(eventType: string): any;
41+
abstract preventDefault(evt);
42+
abstract isPrevented(evt): boolean;
43+
abstract getInnerHTML(el): string;
44+
abstract getOuterHTML(el): string;
45+
abstract nodeName(node): string;
46+
abstract nodeValue(node): string;
47+
abstract type(node): string;
48+
abstract content(node): any;
49+
abstract firstChild(el): Node;
50+
abstract nextSibling(el): Node;
51+
abstract parentElement(el): Node;
52+
abstract childNodes(el): Node[];
53+
abstract childNodesAsList(el): Node[];
54+
abstract clearNodes(el);
55+
abstract appendChild(el, node);
56+
abstract removeChild(el, node);
57+
abstract replaceChild(el, newNode, oldNode);
58+
abstract remove(el): Node;
59+
abstract insertBefore(el, node);
60+
abstract insertAllBefore(el, nodes);
61+
abstract insertAfter(el, node);
62+
abstract setInnerHTML(el, value);
63+
abstract getText(el): string;
64+
abstract setText(el, value: string);
65+
abstract getValue(el): string;
66+
abstract setValue(el, value: string);
67+
abstract getChecked(el): boolean;
68+
abstract setChecked(el, value: boolean);
69+
abstract createComment(text: string): any;
70+
abstract createTemplate(html): HTMLElement;
71+
abstract createElement(tagName, doc?): HTMLElement;
72+
abstract createTextNode(text: string, doc?): Text;
73+
abstract createScriptTag(attrName: string, attrValue: string, doc?): HTMLElement;
74+
abstract createStyleElement(css: string, doc?): HTMLStyleElement;
75+
abstract createShadowRoot(el): any;
76+
abstract getShadowRoot(el): any;
77+
abstract getHost(el): any;
78+
abstract getDistributedNodes(el): Node[];
79+
abstract clone /*<T extends Node>*/ (node: Node /*T*/): Node /*T*/;
80+
abstract getElementsByClassName(element, name: string): HTMLElement[];
81+
abstract getElementsByTagName(element, name: string): HTMLElement[];
82+
abstract classList(element): any[];
83+
abstract addClass(element, classname: string);
84+
abstract removeClass(element, classname: string);
85+
abstract hasClass(element, classname: string): boolean;
86+
abstract setStyle(element, stylename: string, stylevalue: string);
87+
abstract removeStyle(element, stylename: string);
88+
abstract getStyle(element, stylename: string): string;
89+
abstract tagName(element): string;
90+
abstract attributeMap(element): Map<string, string>;
91+
abstract hasAttribute(element, attribute: string): boolean;
92+
abstract getAttribute(element, attribute: string): string;
93+
abstract setAttribute(element, name: string, value: string);
94+
abstract removeAttribute(element, attribute: string);
95+
abstract templateAwareRoot(el);
96+
abstract createHtmlDocument(): HTMLDocument;
97+
abstract defaultDoc(): HTMLDocument;
98+
abstract getBoundingClientRect(el);
99+
abstract getTitle(): string;
100+
abstract setTitle(newTitle: string);
101+
abstract elementMatches(n, selector: string): boolean;
102+
abstract isTemplateElement(el: any): boolean;
103+
abstract isTextNode(node): boolean;
104+
abstract isCommentNode(node): boolean;
105+
abstract isElementNode(node): boolean;
106+
abstract hasShadowRoot(node): boolean;
107+
abstract isShadowRoot(node): boolean;
108+
abstract importIntoDoc /*<T extends Node>*/ (node: Node /*T*/): Node /*T*/;
109+
abstract adoptNode /*<T extends Node>*/ (node: Node /*T*/): Node /*T*/;
110+
abstract isPageRule(rule): boolean;
111+
abstract isStyleRule(rule): boolean;
112+
abstract isMediaRule(rule): boolean;
113+
abstract isKeyframesRule(rule): boolean;
114+
abstract getHref(element): string;
115+
abstract getEventKey(event): string;
116+
abstract resolveAndSetHref(element, baseUrl: string, href: string);
117+
abstract cssToRules(css: string): any[];
118+
abstract supportsDOMEvents(): boolean;
119+
abstract supportsNativeShadowDOM(): boolean;
120+
abstract getGlobalEventTarget(target: string): any;
121+
abstract getHistory(): History;
122+
abstract getLocation(): Location;
123+
abstract getBaseHref(): string;
124+
abstract resetBaseElement(): void;
125+
abstract getUserAgent(): string;
126+
abstract setData(element, name: string, value: string);
127+
abstract getComputedStyle(element): any;
128+
abstract getData(element, name: string): string;
129+
abstract setGlobalVar(name: string, value: any);
130+
abstract requestAnimationFrame(callback): number;
131+
abstract cancelAnimationFrame(id);
132+
abstract performanceNow(): number;
133+
abstract getAnimationPrefix(): string;
134+
abstract getTransitionEnd(): string;
135+
abstract supportsAnimation(): boolean;
145136
}

modules/angular2/src/core/dom/generic_browser_adapter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {DomAdapter} from './dom_adapter';
55
/**
66
* Provides DOM operations in any browser environment.
77
*/
8-
export class GenericBrowserDomAdapter extends DomAdapter {
8+
export abstract class GenericBrowserDomAdapter extends DomAdapter {
99
private _animationPrefix: string = null;
1010
private _transitionEnd: string = null;
1111
constructor() {

modules/angular2/src/core/dom/html_adapter.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ class Html5LibDomAdapter implements DomAdapter {
4646
'tabindex': 'tabIndex',
4747
};
4848

49+
set attrToPropMap(value) {
50+
throw 'readonly';
51+
}
52+
4953
@override
5054
getGlobalEventTarget(String target) {
5155
throw 'not implemented';

modules/angular2/src/core/dom/parse5_adapter.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -562,6 +562,11 @@ export class Parse5DomAdapter extends DomAdapter {
562562
getAnimationPrefix(): string { return ''; }
563563
getTransitionEnd(): string { return 'transitionend'; }
564564
supportsAnimation(): boolean { return true; }
565+
566+
replaceChild(el, newNode, oldNode) { throw new Error('not implemented'); }
567+
parse(templateHtml: string) { throw new Error('not implemented'); }
568+
invoke(el: Element, methodName: string, args: any[]): any { throw new Error('not implemented'); }
569+
getEventKey(event): string { throw new Error('not implemented'); }
565570
}
566571

567572
// TODO: build a proper list, this one is all the keys of a HTMLInputElement

modules/angular2/src/core/facade/lang.dart

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,6 @@ class CONST {
1717
const CONST();
1818
}
1919

20-
class ABSTRACT {
21-
const ABSTRACT();
22-
}
23-
2420
bool isPresent(obj) => obj != null;
2521
bool isBlank(obj) => obj == null;
2622
bool isString(obj) => obj is String;

modules/angular2/src/core/facade/lang.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,6 @@ export function CONST(): ClassDecorator {
6262
return (target) => target;
6363
}
6464

65-
export function ABSTRACT(): ClassDecorator {
66-
return (t) => t;
67-
}
68-
6965
export function isPresent(obj: any): boolean {
7066
return obj !== undefined && obj !== null;
7167
}

modules/angular2/src/core/forms/directives/ng_control.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,13 @@ import {ControlValueAccessor} from './control_value_accessor';
22
import {AbstractControlDirective} from './abstract_control_directive';
33

44
/**
5-
* An abstract class that all control directive extend.
6-
*
5+
* A base class that all control directive extend.
76
* It binds a {@link Control} object to a DOM element.
87
*/
8+
// Cannot currently be abstract because it would contain
9+
// an abstract method in the public API, and we cannot reflect
10+
// on that in Dart due to https://github.com/dart-lang/sdk/issues/18721
11+
// Also we don't have abstract setters, see https://github.com/Microsoft/TypeScript/issues/4669
912
export class NgControl extends AbstractControlDirective {
1013
name: string = null;
1114
valueAccessor: ControlValueAccessor = null;

0 commit comments

Comments
 (0)