Skip to content

Commit 27e7100

Browse files
committed
chore(typing): use types for DOM API
This is possible now that ts2dart special cases these for dart. Fixes angular#2770
1 parent c2c361e commit 27e7100

File tree

8 files changed

+4520
-52
lines changed

8 files changed

+4520
-52
lines changed

modules/angular2/src/dom/dom_adapter.ts

Lines changed: 22 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,9 @@ function _abstract() {
1717
*/
1818
export class DomAdapter {
1919
hasProperty(element, name: string): boolean { throw _abstract(); }
20-
setProperty(el: /*(#2770) Element*/ any, name: string, value: any) { throw _abstract(); }
21-
getProperty(el: /*(#2770) Element*/ any, name: string): any { throw _abstract(); }
22-
invoke(el: /*(#2770) Element*/ any, methodName: string, args: List<any>): any {
23-
throw _abstract();
24-
}
20+
setProperty(el: Element, name: string, value: any) { throw _abstract(); }
21+
getProperty(el: Element, name: string): any { throw _abstract(); }
22+
invoke(el: Element, methodName: string, args: List<any>): any { throw _abstract(); }
2523

2624
logError(error) { throw _abstract(); }
2725

@@ -47,16 +45,16 @@ export class DomAdapter {
4745
nodeValue(node): string { throw _abstract(); }
4846
type(node): string { throw _abstract(); }
4947
content(node): any { throw _abstract(); }
50-
firstChild(el): /*(#2770) Node*/ any { throw _abstract(); }
51-
nextSibling(el): /*(#2770) Node*/ any { throw _abstract(); }
52-
parentElement(el): /*(#2770) Node*/ any { throw _abstract(); }
53-
childNodes(el): List</*(#2770) Node*/ any> { throw _abstract(); }
54-
childNodesAsList(el): List</*(#2770) Node*/ any> { throw _abstract(); }
48+
firstChild(el): Node { throw _abstract(); }
49+
nextSibling(el): Node { throw _abstract(); }
50+
parentElement(el): Node { throw _abstract(); }
51+
childNodes(el): List<Node> { throw _abstract(); }
52+
childNodesAsList(el): List<Node> { throw _abstract(); }
5553
clearNodes(el) { throw _abstract(); }
5654
appendChild(el, node) { throw _abstract(); }
5755
removeChild(el, node) { throw _abstract(); }
5856
replaceChild(el, newNode, oldNode) { throw _abstract(); }
59-
remove(el): /*(#2770) Node*/ any { throw _abstract(); }
57+
remove(el): Node { throw _abstract(); }
6058
insertBefore(el, node) { throw _abstract(); }
6159
insertAllBefore(el, nodes) { throw _abstract(); }
6260
insertAfter(el, node) { throw _abstract(); }
@@ -67,26 +65,20 @@ export class DomAdapter {
6765
setValue(el, value: string) { throw _abstract(); }
6866
getChecked(el): boolean { throw _abstract(); }
6967
setChecked(el, value: boolean) { throw _abstract(); }
70-
createTemplate(html): /*(#2770) HTMLElement*/ any { throw _abstract(); }
71-
createElement(tagName, doc = null): /*(#2770) HTMLElement*/ any { throw _abstract(); }
72-
createTextNode(text: string, doc = null): /*(#2770) Text*/ any { throw _abstract(); }
73-
createScriptTag(attrName: string, attrValue: string, doc = null): /*(#2770) HTMLElement*/ any {
74-
throw _abstract();
75-
}
76-
createStyleElement(css: string, doc = null): /*(#2770) HTMLStyleElement*/ any {
68+
createTemplate(html): HTMLElement { throw _abstract(); }
69+
createElement(tagName, doc = null): HTMLElement { throw _abstract(); }
70+
createTextNode(text: string, doc = null): Text { throw _abstract(); }
71+
createScriptTag(attrName: string, attrValue: string, doc = null): HTMLElement {
7772
throw _abstract();
7873
}
74+
createStyleElement(css: string, doc = null): HTMLStyleElement { throw _abstract(); }
7975
createShadowRoot(el): any { throw _abstract(); }
8076
getShadowRoot(el): any { throw _abstract(); }
8177
getHost(el): any { throw _abstract(); }
82-
getDistributedNodes(el): List</*(#2770) Node*/ any> { throw _abstract(); }
83-
clone(node: /*(#2770) Node*/ any): /*(#2770) Node*/ any { throw _abstract(); }
84-
getElementsByClassName(element, name: string): List</*(#2770) HTMLElement*/ any> {
85-
throw _abstract();
86-
}
87-
getElementsByTagName(element, name: string): List</*(#2770) HTMLElement*/ any> {
88-
throw _abstract();
89-
}
78+
getDistributedNodes(el): List<Node> { throw _abstract(); }
79+
clone(node: Node): Node { throw _abstract(); }
80+
getElementsByClassName(element, name: string): List<HTMLElement> { throw _abstract(); }
81+
getElementsByTagName(element, name: string): List<HTMLElement> { throw _abstract(); }
9082
classList(element): List<any> { throw _abstract(); }
9183
addClass(element, classname: string) { throw _abstract(); }
9284
removeClass(element, classname: string) { throw _abstract(); }
@@ -101,8 +93,8 @@ export class DomAdapter {
10193
setAttribute(element, name: string, value: string) { throw _abstract(); }
10294
removeAttribute(element, attribute: string) { throw _abstract(); }
10395
templateAwareRoot(el) { throw _abstract(); }
104-
createHtmlDocument(): /*(#2770) HTMLDocument*/ any { throw _abstract(); }
105-
defaultDoc(): /*(#2770) HTMLDocument*/ any { throw _abstract(); }
96+
createHtmlDocument(): HTMLDocument { throw _abstract(); }
97+
defaultDoc(): HTMLDocument { throw _abstract(); }
10698
getBoundingClientRect(el) { throw _abstract(); }
10799
getTitle(): string { throw _abstract(); }
108100
setTitle(newTitle: string) { throw _abstract(); }
@@ -125,8 +117,8 @@ export class DomAdapter {
125117
supportsDOMEvents(): boolean { throw _abstract(); }
126118
supportsNativeShadowDOM(): boolean { throw _abstract(); }
127119
getGlobalEventTarget(target: string): any { throw _abstract(); }
128-
getHistory(): /*(#2770) History*/ any { throw _abstract(); }
129-
getLocation(): /*(#2770) Location*/ any { throw _abstract(); }
120+
getHistory(): History { throw _abstract(); }
121+
getLocation(): Location { throw _abstract(); }
130122
getBaseHref(): string { throw _abstract(); }
131123
getUserAgent(): string { throw _abstract(); }
132124
setData(element, name: string, value: string) { throw _abstract(); }

modules/angular2/src/dom/generic_browser_adapter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {DomAdapter} from './dom_adapter';
66
* Provides DOM operations in any browser environment.
77
*/
88
export class GenericBrowserDomAdapter extends DomAdapter {
9-
getDistributedNodes(el): List</*(#2770) Node*/ any> { return el.getDistributedNodes(); }
9+
getDistributedNodes(el): List<Node> { return el.getDistributedNodes(); }
1010
resolveAndSetHref(el, baseUrl: string, href: string) {
1111
el.href = href == null ? baseUrl : baseUrl + '/../' + href;
1212
}

modules/angular2/src/render/dom/shadow_dom/emulated_unscoped_shadow_dom_strategy.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export class EmulatedUnscopedShadowDomStrategy extends ShadowDomStrategy {
2020

2121
hasNativeContentElement(): boolean { return false; }
2222

23-
prepareShadowRoot(el): /*(#2770) Node*/ any { return el; }
23+
prepareShadowRoot(el): Node { return el; }
2424

2525
constructLightDom(lightDomView: viewModule.DomView, el): LightDom {
2626
return new LightDom(lightDomView, el);

modules/angular2/src/render/dom/shadow_dom/native_shadow_dom_strategy.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@ import {ShadowDomStrategy} from './shadow_dom_strategy';
1010
*/
1111
@Injectable()
1212
export class NativeShadowDomStrategy extends ShadowDomStrategy {
13-
prepareShadowRoot(el): /*(#2770) Node*/ any { return DOM.createShadowRoot(el); }
13+
prepareShadowRoot(el): Node { return DOM.createShadowRoot(el); }
1414
}

modules/angular2/test/core/compiler/dynamic_component_loader_spec.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,7 @@ export function main() {
115115
tc.detectChanges();
116116

117117
var newlyInsertedElement = DOM.childNodes(tc.nativeElement)[1];
118-
expect((</*(#2770) HTMLElement*/ any>newlyInsertedElement).id)
119-
.toEqual("new value");
118+
expect((<HTMLElement>newlyInsertedElement).id).toEqual("new value");
120119
async.done();
121120
});
122121
});
@@ -210,8 +209,7 @@ export function main() {
210209
tc.detectChanges();
211210

212211
var newlyInsertedElement = DOM.nextSibling(tc.nativeElement);
213-
expect((</*(#2770) HTMLElement*/ any>newlyInsertedElement).id)
214-
.toEqual("new value");
212+
expect((<HTMLElement>newlyInsertedElement).id).toEqual("new value");
215213

216214
async.done();
217215
});

modules/angular2/test/render/dom/dom_renderer_integration_spec.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,11 +107,10 @@ export function main() {
107107

108108
var el = DOM.childNodes(tb.rootEl)[0];
109109
tb.renderer.setElementProperty(elRef(cmpView.viewRef, 0), 'value', 'hello');
110-
expect((</*(#2770) HTMLInputElement*/ any>el).value).toEqual('hello');
110+
expect((<HTMLInputElement>el).value).toEqual('hello');
111111

112112
tb.renderer.setElementClass(elRef(cmpView.viewRef, 0), 'a', true);
113-
expect((</*(#2770) HTMLInputElement*/ any>DOM.childNodes(tb.rootEl)[0]).value)
114-
.toEqual('hello');
113+
expect((<HTMLInputElement>DOM.childNodes(tb.rootEl)[0]).value).toEqual('hello');
115114
tb.renderer.setElementClass(elRef(cmpView.viewRef, 0), 'a', false);
116115
expect(DOM.hasClass(el, 'a')).toBe(false);
117116

0 commit comments

Comments
 (0)