chore(typing): use types for DOM API
This is possible now that ts2dart special cases these for dart. Fixes #2770
This commit is contained in:
parent
c2c361efcf
commit
27e710019c
|
@ -17,11 +17,9 @@ function _abstract() {
|
||||||
*/
|
*/
|
||||||
export class DomAdapter {
|
export class DomAdapter {
|
||||||
hasProperty(element, name: string): boolean { throw _abstract(); }
|
hasProperty(element, name: string): boolean { throw _abstract(); }
|
||||||
setProperty(el: /*(#2770) Element*/ any, name: string, value: any) { throw _abstract(); }
|
setProperty(el: Element, name: string, value: any) { throw _abstract(); }
|
||||||
getProperty(el: /*(#2770) Element*/ any, name: string): any { throw _abstract(); }
|
getProperty(el: Element, name: string): any { throw _abstract(); }
|
||||||
invoke(el: /*(#2770) Element*/ any, methodName: string, args: List<any>): any {
|
invoke(el: Element, methodName: string, args: List<any>): any { throw _abstract(); }
|
||||||
throw _abstract();
|
|
||||||
}
|
|
||||||
|
|
||||||
logError(error) { throw _abstract(); }
|
logError(error) { throw _abstract(); }
|
||||||
|
|
||||||
|
@ -47,16 +45,16 @@ export class DomAdapter {
|
||||||
nodeValue(node): string { throw _abstract(); }
|
nodeValue(node): string { throw _abstract(); }
|
||||||
type(node): string { throw _abstract(); }
|
type(node): string { throw _abstract(); }
|
||||||
content(node): any { throw _abstract(); }
|
content(node): any { throw _abstract(); }
|
||||||
firstChild(el): /*(#2770) Node*/ any { throw _abstract(); }
|
firstChild(el): Node { throw _abstract(); }
|
||||||
nextSibling(el): /*(#2770) Node*/ any { throw _abstract(); }
|
nextSibling(el): Node { throw _abstract(); }
|
||||||
parentElement(el): /*(#2770) Node*/ any { throw _abstract(); }
|
parentElement(el): Node { throw _abstract(); }
|
||||||
childNodes(el): List</*(#2770) Node*/ any> { throw _abstract(); }
|
childNodes(el): List<Node> { throw _abstract(); }
|
||||||
childNodesAsList(el): List</*(#2770) Node*/ any> { throw _abstract(); }
|
childNodesAsList(el): List<Node> { throw _abstract(); }
|
||||||
clearNodes(el) { throw _abstract(); }
|
clearNodes(el) { throw _abstract(); }
|
||||||
appendChild(el, node) { throw _abstract(); }
|
appendChild(el, node) { throw _abstract(); }
|
||||||
removeChild(el, node) { throw _abstract(); }
|
removeChild(el, node) { throw _abstract(); }
|
||||||
replaceChild(el, newNode, oldNode) { throw _abstract(); }
|
replaceChild(el, newNode, oldNode) { throw _abstract(); }
|
||||||
remove(el): /*(#2770) Node*/ any { throw _abstract(); }
|
remove(el): Node { throw _abstract(); }
|
||||||
insertBefore(el, node) { throw _abstract(); }
|
insertBefore(el, node) { throw _abstract(); }
|
||||||
insertAllBefore(el, nodes) { throw _abstract(); }
|
insertAllBefore(el, nodes) { throw _abstract(); }
|
||||||
insertAfter(el, node) { throw _abstract(); }
|
insertAfter(el, node) { throw _abstract(); }
|
||||||
|
@ -67,26 +65,20 @@ export class DomAdapter {
|
||||||
setValue(el, value: string) { throw _abstract(); }
|
setValue(el, value: string) { throw _abstract(); }
|
||||||
getChecked(el): boolean { throw _abstract(); }
|
getChecked(el): boolean { throw _abstract(); }
|
||||||
setChecked(el, value: boolean) { throw _abstract(); }
|
setChecked(el, value: boolean) { throw _abstract(); }
|
||||||
createTemplate(html): /*(#2770) HTMLElement*/ any { throw _abstract(); }
|
createTemplate(html): HTMLElement { throw _abstract(); }
|
||||||
createElement(tagName, doc = null): /*(#2770) HTMLElement*/ any { throw _abstract(); }
|
createElement(tagName, doc = null): HTMLElement { throw _abstract(); }
|
||||||
createTextNode(text: string, doc = null): /*(#2770) Text*/ any { throw _abstract(); }
|
createTextNode(text: string, doc = null): Text { throw _abstract(); }
|
||||||
createScriptTag(attrName: string, attrValue: string, doc = null): /*(#2770) HTMLElement*/ any {
|
createScriptTag(attrName: string, attrValue: string, doc = null): HTMLElement {
|
||||||
throw _abstract();
|
|
||||||
}
|
|
||||||
createStyleElement(css: string, doc = null): /*(#2770) HTMLStyleElement*/ any {
|
|
||||||
throw _abstract();
|
throw _abstract();
|
||||||
}
|
}
|
||||||
|
createStyleElement(css: string, doc = null): HTMLStyleElement { throw _abstract(); }
|
||||||
createShadowRoot(el): any { throw _abstract(); }
|
createShadowRoot(el): any { throw _abstract(); }
|
||||||
getShadowRoot(el): any { throw _abstract(); }
|
getShadowRoot(el): any { throw _abstract(); }
|
||||||
getHost(el): any { throw _abstract(); }
|
getHost(el): any { throw _abstract(); }
|
||||||
getDistributedNodes(el): List</*(#2770) Node*/ any> { throw _abstract(); }
|
getDistributedNodes(el): List<Node> { throw _abstract(); }
|
||||||
clone(node: /*(#2770) Node*/ any): /*(#2770) Node*/ any { throw _abstract(); }
|
clone(node: Node): Node { throw _abstract(); }
|
||||||
getElementsByClassName(element, name: string): List</*(#2770) HTMLElement*/ any> {
|
getElementsByClassName(element, name: string): List<HTMLElement> { throw _abstract(); }
|
||||||
throw _abstract();
|
getElementsByTagName(element, name: string): List<HTMLElement> { throw _abstract(); }
|
||||||
}
|
|
||||||
getElementsByTagName(element, name: string): List</*(#2770) HTMLElement*/ any> {
|
|
||||||
throw _abstract();
|
|
||||||
}
|
|
||||||
classList(element): List<any> { throw _abstract(); }
|
classList(element): List<any> { throw _abstract(); }
|
||||||
addClass(element, classname: string) { throw _abstract(); }
|
addClass(element, classname: string) { throw _abstract(); }
|
||||||
removeClass(element, classname: string) { throw _abstract(); }
|
removeClass(element, classname: string) { throw _abstract(); }
|
||||||
|
@ -101,8 +93,8 @@ export class DomAdapter {
|
||||||
setAttribute(element, name: string, value: string) { throw _abstract(); }
|
setAttribute(element, name: string, value: string) { throw _abstract(); }
|
||||||
removeAttribute(element, attribute: string) { throw _abstract(); }
|
removeAttribute(element, attribute: string) { throw _abstract(); }
|
||||||
templateAwareRoot(el) { throw _abstract(); }
|
templateAwareRoot(el) { throw _abstract(); }
|
||||||
createHtmlDocument(): /*(#2770) HTMLDocument*/ any { throw _abstract(); }
|
createHtmlDocument(): HTMLDocument { throw _abstract(); }
|
||||||
defaultDoc(): /*(#2770) HTMLDocument*/ any { throw _abstract(); }
|
defaultDoc(): HTMLDocument { throw _abstract(); }
|
||||||
getBoundingClientRect(el) { throw _abstract(); }
|
getBoundingClientRect(el) { throw _abstract(); }
|
||||||
getTitle(): string { throw _abstract(); }
|
getTitle(): string { throw _abstract(); }
|
||||||
setTitle(newTitle: string) { throw _abstract(); }
|
setTitle(newTitle: string) { throw _abstract(); }
|
||||||
|
@ -125,8 +117,8 @@ export class DomAdapter {
|
||||||
supportsDOMEvents(): boolean { throw _abstract(); }
|
supportsDOMEvents(): boolean { throw _abstract(); }
|
||||||
supportsNativeShadowDOM(): boolean { throw _abstract(); }
|
supportsNativeShadowDOM(): boolean { throw _abstract(); }
|
||||||
getGlobalEventTarget(target: string): any { throw _abstract(); }
|
getGlobalEventTarget(target: string): any { throw _abstract(); }
|
||||||
getHistory(): /*(#2770) History*/ any { throw _abstract(); }
|
getHistory(): History { throw _abstract(); }
|
||||||
getLocation(): /*(#2770) Location*/ any { throw _abstract(); }
|
getLocation(): Location { throw _abstract(); }
|
||||||
getBaseHref(): string { throw _abstract(); }
|
getBaseHref(): string { throw _abstract(); }
|
||||||
getUserAgent(): string { throw _abstract(); }
|
getUserAgent(): string { throw _abstract(); }
|
||||||
setData(element, name: string, value: string) { throw _abstract(); }
|
setData(element, name: string, value: string) { throw _abstract(); }
|
||||||
|
|
|
@ -6,7 +6,7 @@ import {DomAdapter} from './dom_adapter';
|
||||||
* Provides DOM operations in any browser environment.
|
* Provides DOM operations in any browser environment.
|
||||||
*/
|
*/
|
||||||
export class GenericBrowserDomAdapter extends DomAdapter {
|
export class GenericBrowserDomAdapter extends DomAdapter {
|
||||||
getDistributedNodes(el): List</*(#2770) Node*/ any> { return el.getDistributedNodes(); }
|
getDistributedNodes(el): List<Node> { return el.getDistributedNodes(); }
|
||||||
resolveAndSetHref(el, baseUrl: string, href: string) {
|
resolveAndSetHref(el, baseUrl: string, href: string) {
|
||||||
el.href = href == null ? baseUrl : baseUrl + '/../' + href;
|
el.href = href == null ? baseUrl : baseUrl + '/../' + href;
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@ export class EmulatedUnscopedShadowDomStrategy extends ShadowDomStrategy {
|
||||||
|
|
||||||
hasNativeContentElement(): boolean { return false; }
|
hasNativeContentElement(): boolean { return false; }
|
||||||
|
|
||||||
prepareShadowRoot(el): /*(#2770) Node*/ any { return el; }
|
prepareShadowRoot(el): Node { return el; }
|
||||||
|
|
||||||
constructLightDom(lightDomView: viewModule.DomView, el): LightDom {
|
constructLightDom(lightDomView: viewModule.DomView, el): LightDom {
|
||||||
return new LightDom(lightDomView, el);
|
return new LightDom(lightDomView, el);
|
||||||
|
|
|
@ -10,5 +10,5 @@ import {ShadowDomStrategy} from './shadow_dom_strategy';
|
||||||
*/
|
*/
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class NativeShadowDomStrategy extends ShadowDomStrategy {
|
export class NativeShadowDomStrategy extends ShadowDomStrategy {
|
||||||
prepareShadowRoot(el): /*(#2770) Node*/ any { return DOM.createShadowRoot(el); }
|
prepareShadowRoot(el): Node { return DOM.createShadowRoot(el); }
|
||||||
}
|
}
|
||||||
|
|
|
@ -115,8 +115,7 @@ export function main() {
|
||||||
tc.detectChanges();
|
tc.detectChanges();
|
||||||
|
|
||||||
var newlyInsertedElement = DOM.childNodes(tc.nativeElement)[1];
|
var newlyInsertedElement = DOM.childNodes(tc.nativeElement)[1];
|
||||||
expect((</*(#2770) HTMLElement*/ any>newlyInsertedElement).id)
|
expect((<HTMLElement>newlyInsertedElement).id).toEqual("new value");
|
||||||
.toEqual("new value");
|
|
||||||
async.done();
|
async.done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -210,8 +209,7 @@ export function main() {
|
||||||
tc.detectChanges();
|
tc.detectChanges();
|
||||||
|
|
||||||
var newlyInsertedElement = DOM.nextSibling(tc.nativeElement);
|
var newlyInsertedElement = DOM.nextSibling(tc.nativeElement);
|
||||||
expect((</*(#2770) HTMLElement*/ any>newlyInsertedElement).id)
|
expect((<HTMLElement>newlyInsertedElement).id).toEqual("new value");
|
||||||
.toEqual("new value");
|
|
||||||
|
|
||||||
async.done();
|
async.done();
|
||||||
});
|
});
|
||||||
|
|
|
@ -107,11 +107,10 @@ export function main() {
|
||||||
|
|
||||||
var el = DOM.childNodes(tb.rootEl)[0];
|
var el = DOM.childNodes(tb.rootEl)[0];
|
||||||
tb.renderer.setElementProperty(elRef(cmpView.viewRef, 0), 'value', 'hello');
|
tb.renderer.setElementProperty(elRef(cmpView.viewRef, 0), 'value', 'hello');
|
||||||
expect((</*(#2770) HTMLInputElement*/ any>el).value).toEqual('hello');
|
expect((<HTMLInputElement>el).value).toEqual('hello');
|
||||||
|
|
||||||
tb.renderer.setElementClass(elRef(cmpView.viewRef, 0), 'a', true);
|
tb.renderer.setElementClass(elRef(cmpView.viewRef, 0), 'a', true);
|
||||||
expect((</*(#2770) HTMLInputElement*/ any>DOM.childNodes(tb.rootEl)[0]).value)
|
expect((<HTMLInputElement>DOM.childNodes(tb.rootEl)[0]).value).toEqual('hello');
|
||||||
.toEqual('hello');
|
|
||||||
tb.renderer.setElementClass(elRef(cmpView.viewRef, 0), 'a', false);
|
tb.renderer.setElementClass(elRef(cmpView.viewRef, 0), 'a', false);
|
||||||
expect(DOM.hasClass(el, 'a')).toBe(false);
|
expect(DOM.hasClass(el, 'a')).toBe(false);
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue