refactor(core): remove misc, completely unused functions from DomAdapter (#32278)
PR Close #32278
This commit is contained in:
parent
bceeeba405
commit
24127a2492
|
@ -28,7 +28,7 @@
|
|||
"uncompressed": {
|
||||
"runtime-es5": 2932,
|
||||
"runtime-es2015": 2938,
|
||||
"main-es5": 560811,
|
||||
"main-es5": 554933,
|
||||
"main-es2015": 499846,
|
||||
"polyfills-es5": 131024,
|
||||
"polyfills-es2015": 52433
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
"master": {
|
||||
"uncompressed": {
|
||||
"runtime": 1497,
|
||||
"main": 166799,
|
||||
"main": 164387,
|
||||
"polyfills": 45399
|
||||
}
|
||||
}
|
||||
|
@ -21,7 +21,7 @@
|
|||
"master": {
|
||||
"uncompressed": {
|
||||
"runtime": 1440,
|
||||
"main": 134091,
|
||||
"main": 130975,
|
||||
"polyfills": 45340
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,13 +6,13 @@
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {supportsWebAnimation} from '@angular/platform-browser/testing/src/browser_util';
|
||||
import {describe, expect, it} from '@angular/core/testing/src/testing_internal';
|
||||
import {RequestOptions} from '@angular/http/src/base_request_options';
|
||||
import {ContentType} from '@angular/http/src/enums';
|
||||
import {Headers} from '@angular/http/src/headers';
|
||||
import {stringToArrayBuffer, stringToArrayBuffer8} from '@angular/http/src/http_utils';
|
||||
import {ArrayBuffer, Request} from '@angular/http/src/static_request';
|
||||
import {supportsWebAnimation} from '@angular/platform-browser/testing/src/browser_util';
|
||||
|
||||
{
|
||||
describe('Request', () => {
|
||||
|
|
|
@ -374,14 +374,6 @@ const SCHEMA: string[] = [
|
|||
':svg:cursor^:svg:|',
|
||||
];
|
||||
|
||||
const attrToPropMap: {[name: string]: string} = <any>{
|
||||
'class': 'className',
|
||||
'formaction': 'formAction',
|
||||
'innerHtml': 'innerHTML',
|
||||
'readonly': 'readOnly',
|
||||
'tabindex': 'tabIndex'
|
||||
};
|
||||
|
||||
const EVENT = 'event';
|
||||
const BOOLEAN = 'boolean';
|
||||
const NUMBER = 'number';
|
||||
|
|
|
@ -13,12 +13,6 @@ import {setRootDomAdapter} from '../dom/dom_adapter';
|
|||
|
||||
import {GenericBrowserDomAdapter} from './generic_browser_adapter';
|
||||
|
||||
const _attrToPropMap = {
|
||||
'class': 'className',
|
||||
'innerHtml': 'innerHTML',
|
||||
'readonly': 'readOnly',
|
||||
'tabindex': 'tabIndex',
|
||||
};
|
||||
|
||||
const DOM_KEY_LOCATION_NUMPAD = 3;
|
||||
|
||||
|
@ -117,8 +111,6 @@ export class BrowserDomAdapter extends GenericBrowserDomAdapter {
|
|||
}
|
||||
}
|
||||
|
||||
get attrToPropMap(): any { return _attrToPropMap; }
|
||||
|
||||
contains(nodeA: any, nodeB: any): boolean { return nodeContains.call(nodeA, nodeB); }
|
||||
querySelector(el: HTMLElement, selector: string): any { return el.querySelector(selector); }
|
||||
querySelectorAll(el: any, selector: string): any[] { return el.querySelectorAll(selector); }
|
||||
|
@ -147,9 +139,6 @@ export class BrowserDomAdapter extends GenericBrowserDomAdapter {
|
|||
isPrevented(evt: Event): boolean {
|
||||
return evt.defaultPrevented || evt.returnValue != null && !evt.returnValue;
|
||||
}
|
||||
getTemplateContent(el: Node): Node|null {
|
||||
return 'content' in el && this.isTemplateElement(el) ? (<any>el).content : null;
|
||||
}
|
||||
nodeName(node: Node): string { return node.nodeName; }
|
||||
nodeValue(node: Node): string|null { return node.nodeValue; }
|
||||
type(node: HTMLInputElement): string { return node.type; }
|
||||
|
@ -179,7 +168,6 @@ export class BrowserDomAdapter extends GenericBrowserDomAdapter {
|
|||
}
|
||||
appendChild(el: Node, node: Node) { el.appendChild(node); }
|
||||
removeChild(el: Node, node: Node) { el.removeChild(node); }
|
||||
replaceChild(el: Node, newChild: Node, oldChild: Node) { el.replaceChild(newChild, oldChild); }
|
||||
remove(node: Node): Node {
|
||||
if (node.parentNode) {
|
||||
node.parentNode.removeChild(node);
|
||||
|
@ -187,17 +175,11 @@ export class BrowserDomAdapter extends GenericBrowserDomAdapter {
|
|||
return node;
|
||||
}
|
||||
insertBefore(parent: Node, ref: Node, node: Node) { parent.insertBefore(node, ref); }
|
||||
insertAllBefore(parent: Node, ref: Node, nodes: Node[]) {
|
||||
nodes.forEach((n: any) => parent.insertBefore(n, ref));
|
||||
}
|
||||
insertAfter(parent: Node, ref: Node, node: any) { parent.insertBefore(node, ref.nextSibling); }
|
||||
setInnerHTML(el: Element, value: string) { el.innerHTML = value; }
|
||||
getText(el: Node): string|null { return el.textContent; }
|
||||
setText(el: Node, value: string) { el.textContent = value; }
|
||||
getValue(el: any): string { return el.value; }
|
||||
setValue(el: any, value: string) { el.value = value; }
|
||||
getChecked(el: any): boolean { return el.checked; }
|
||||
setChecked(el: any, value: boolean) { el.checked = value; }
|
||||
createComment(text: string): Comment { return this.getDefaultDocument().createComment(text); }
|
||||
createTemplate(html: any): HTMLElement {
|
||||
const t = this.getDefaultDocument().createElement('template');
|
||||
|
@ -216,25 +198,10 @@ export class BrowserDomAdapter extends GenericBrowserDomAdapter {
|
|||
doc = doc || this.getDefaultDocument();
|
||||
return doc.createTextNode(text);
|
||||
}
|
||||
createScriptTag(attrName: string, attrValue: string, doc?: Document): HTMLScriptElement {
|
||||
doc = doc || this.getDefaultDocument();
|
||||
const el = <HTMLScriptElement>doc.createElement('SCRIPT');
|
||||
el.setAttribute(attrName, attrValue);
|
||||
return el;
|
||||
}
|
||||
createStyleElement(css: string, doc?: Document): HTMLStyleElement {
|
||||
doc = doc || this.getDefaultDocument();
|
||||
const style = <HTMLStyleElement>doc.createElement('style');
|
||||
this.appendChild(style, this.createTextNode(css, doc));
|
||||
return style;
|
||||
}
|
||||
createShadowRoot(el: HTMLElement): DocumentFragment { return (<any>el).createShadowRoot(); }
|
||||
getShadowRoot(el: HTMLElement): DocumentFragment { return (<any>el).shadowRoot; }
|
||||
getHost(el: HTMLElement): HTMLElement { return (<any>el).host; }
|
||||
clone(node: Node): Node { return node.cloneNode(true); }
|
||||
getElementsByClassName(element: any, name: string): HTMLElement[] {
|
||||
return element.getElementsByClassName(name);
|
||||
}
|
||||
getElementsByTagName(element: any, name: string): HTMLElement[] {
|
||||
return element.getElementsByTagName(name);
|
||||
}
|
||||
|
@ -278,13 +245,6 @@ export class BrowserDomAdapter extends GenericBrowserDomAdapter {
|
|||
return document.implementation.createHTMLDocument('fakeTitle');
|
||||
}
|
||||
getDefaultDocument(): Document { return document; }
|
||||
getBoundingClientRect(el: Element): any {
|
||||
try {
|
||||
return el.getBoundingClientRect();
|
||||
} catch {
|
||||
return {top: 0, bottom: 0, left: 0, right: 0, width: 0, height: 0};
|
||||
}
|
||||
}
|
||||
getTitle(doc: Document): string { return doc.title; }
|
||||
setTitle(doc: Document, newTitle: string) { doc.title = newTitle || ''; }
|
||||
elementMatches(n: any, selector: string): boolean {
|
||||
|
@ -305,8 +265,6 @@ export class BrowserDomAdapter extends GenericBrowserDomAdapter {
|
|||
return node.shadowRoot != null && node instanceof HTMLElement;
|
||||
}
|
||||
isShadowRoot(node: any): boolean { return node instanceof DocumentFragment; }
|
||||
importIntoDoc(node: Node): any { return document.importNode(this.templateAwareRoot(node), true); }
|
||||
adoptNode(node: Node): any { return document.adoptNode(node); }
|
||||
getHref(el: Element): string { return el.getAttribute('href') !; }
|
||||
|
||||
getEventKey(event: any): string {
|
||||
|
|
|
@ -20,9 +20,6 @@ export abstract class GenericBrowserDomAdapter extends DomAdapter {
|
|||
constructor() { super(); }
|
||||
|
||||
getDistributedNodes(el: HTMLElement): Node[] { return (<any>el).getDistributedNodes(); }
|
||||
resolveAndSetHref(el: HTMLAnchorElement, baseUrl: string, href: string) {
|
||||
el.href = href == null ? baseUrl : baseUrl + '/../' + href;
|
||||
}
|
||||
supportsDOMEvents(): boolean { return true; }
|
||||
supportsNativeShadowDOM(): boolean {
|
||||
return typeof(<any>document.body).createShadowRoot === 'function';
|
||||
|
|
|
@ -32,7 +32,6 @@ export function setRootDomAdapter(adapter: DomAdapter) {
|
|||
* can introduce XSS risks.
|
||||
*/
|
||||
export abstract class DomAdapter {
|
||||
public resourceLoaderType: Type<any> = null !;
|
||||
abstract hasProperty(element: any, name: string): boolean;
|
||||
abstract setProperty(el: Element, name: string, value: any): any;
|
||||
abstract getProperty(el: Element, name: string): any;
|
||||
|
@ -43,16 +42,6 @@ export abstract class DomAdapter {
|
|||
abstract logGroup(error: any): any;
|
||||
abstract logGroupEnd(): any;
|
||||
|
||||
/**
|
||||
* Maps attribute names to their corresponding property names for cases
|
||||
* where attribute name doesn't match property name.
|
||||
*/
|
||||
get attrToPropMap(): {[key: string]: string} { return this._attrToPropMap; }
|
||||
set attrToPropMap(value: {[key: string]: string}) { this._attrToPropMap = value; }
|
||||
/** @internal */
|
||||
// TODO(issue/24571): remove '!'.
|
||||
_attrToPropMap !: {[key: string]: string};
|
||||
|
||||
abstract contains(nodeA: any, nodeB: any): boolean;
|
||||
abstract parse(templateHtml: string): any;
|
||||
abstract querySelector(el: any, selector: string): any;
|
||||
|
@ -64,8 +53,6 @@ export abstract class DomAdapter {
|
|||
abstract createEvent(eventType: string): any;
|
||||
abstract preventDefault(evt: any): any;
|
||||
abstract isPrevented(evt: any): boolean;
|
||||
/** Returns content if el is a <template> element, null otherwise. */
|
||||
abstract getTemplateContent(el: any): any;
|
||||
abstract nodeName(node: any): string;
|
||||
abstract nodeValue(node: any): string|null;
|
||||
abstract type(node: any): string;
|
||||
|
@ -78,31 +65,23 @@ export abstract class DomAdapter {
|
|||
abstract clearNodes(el: any): any;
|
||||
abstract appendChild(el: any, node: any): any;
|
||||
abstract removeChild(el: any, node: any): any;
|
||||
abstract replaceChild(el: any, newNode: any, oldNode: any): any;
|
||||
abstract remove(el: any): Node;
|
||||
abstract insertBefore(parent: any, ref: any, node: any): any;
|
||||
abstract insertAllBefore(parent: any, ref: any, nodes: any): any;
|
||||
abstract insertAfter(parent: any, el: any, node: any): any;
|
||||
abstract setInnerHTML(el: any, value: any): any;
|
||||
abstract getText(el: any): string|null;
|
||||
abstract setText(el: any, value: string): any;
|
||||
abstract getValue(el: any): string;
|
||||
abstract setValue(el: any, value: string): any;
|
||||
abstract getChecked(el: any): boolean;
|
||||
abstract setChecked(el: any, value: boolean): any;
|
||||
abstract createComment(text: string): any;
|
||||
abstract createTemplate(html: any): HTMLElement;
|
||||
abstract createElement(tagName: any, doc?: any): HTMLElement;
|
||||
abstract createElementNS(ns: string, tagName: string, doc?: any): Element;
|
||||
abstract createTextNode(text: string, doc?: any): Text;
|
||||
abstract createScriptTag(attrName: string, attrValue: string, doc?: any): HTMLElement;
|
||||
abstract createStyleElement(css: string, doc?: any): HTMLStyleElement;
|
||||
abstract createShadowRoot(el: any): any;
|
||||
abstract getShadowRoot(el: any): any;
|
||||
abstract getHost(el: any): any;
|
||||
abstract getDistributedNodes(el: any): Node[];
|
||||
abstract clone /*<T extends Node>*/ (node: Node /*T*/): Node /*T*/;
|
||||
abstract getElementsByClassName(element: any, name: string): HTMLElement[];
|
||||
abstract getElementsByTagName(element: any, name: string): HTMLElement[];
|
||||
abstract classList(element: any): any[];
|
||||
abstract addClass(element: any, className: string): any;
|
||||
|
@ -122,7 +101,6 @@ export abstract class DomAdapter {
|
|||
abstract templateAwareRoot(el: any): any;
|
||||
abstract createHtmlDocument(): HTMLDocument;
|
||||
abstract getDefaultDocument(): Document;
|
||||
abstract getBoundingClientRect(el: any): any;
|
||||
abstract getTitle(doc: Document): string;
|
||||
abstract setTitle(doc: Document, newTitle: string): any;
|
||||
abstract elementMatches(n: any, selector: string): boolean;
|
||||
|
@ -131,11 +109,8 @@ export abstract class DomAdapter {
|
|||
abstract isElementNode(node: any): boolean;
|
||||
abstract hasShadowRoot(node: any): boolean;
|
||||
abstract isShadowRoot(node: any): boolean;
|
||||
abstract importIntoDoc /*<T extends Node>*/ (node: Node /*T*/): Node /*T*/;
|
||||
abstract adoptNode /*<T extends Node>*/ (node: Node /*T*/): Node /*T*/;
|
||||
abstract getHref(element: any): string;
|
||||
abstract getEventKey(event: any): string;
|
||||
abstract resolveAndSetHref(element: any, baseUrl: string, href: string): any;
|
||||
abstract supportsDOMEvents(): boolean;
|
||||
abstract supportsNativeShadowDOM(): boolean;
|
||||
abstract getGlobalEventTarget(doc: Document, target: string): any;
|
||||
|
@ -143,6 +118,8 @@ export abstract class DomAdapter {
|
|||
abstract getLocation(): Location;
|
||||
abstract getBaseHref(doc: Document): string|null;
|
||||
abstract resetBaseElement(): void;
|
||||
|
||||
// TODO: remove dependency in DefaultValueAccessor
|
||||
abstract getUserAgent(): string;
|
||||
|
||||
// Used by AngularProfiler
|
||||
|
|
|
@ -52,9 +52,6 @@ export class WorkerDomAdapter extends DomAdapter {
|
|||
getProperty(el: Element, name: string): any { throw 'not implemented'; }
|
||||
invoke(el: Element, methodName: string, args: any[]): any { throw 'not implemented'; }
|
||||
|
||||
get attrToPropMap(): {[key: string]: string} { throw 'not implemented'; }
|
||||
set attrToPropMap(value: {[key: string]: string}) { throw 'not implemented'; }
|
||||
|
||||
parse(templateHtml: string) { throw 'not implemented'; }
|
||||
querySelector(el: any, selector: string): HTMLElement { throw 'not implemented'; }
|
||||
querySelectorAll(el: any, selector: string): any[] { throw 'not implemented'; }
|
||||
|
@ -65,7 +62,6 @@ export class WorkerDomAdapter extends DomAdapter {
|
|||
createEvent(eventType: string): any { throw 'not implemented'; }
|
||||
preventDefault(evt: any) { throw 'not implemented'; }
|
||||
isPrevented(evt: any): boolean { throw 'not implemented'; }
|
||||
getTemplateContent(el: any): any { throw 'not implemented'; }
|
||||
nodeName(node: any): string { throw 'not implemented'; }
|
||||
nodeValue(node: any): string { throw 'not implemented'; }
|
||||
type(node: any): string { throw 'not implemented'; }
|
||||
|
@ -78,33 +74,23 @@ export class WorkerDomAdapter extends DomAdapter {
|
|||
clearNodes(el: any) { throw 'not implemented'; }
|
||||
appendChild(el: any, node: any) { throw 'not implemented'; }
|
||||
removeChild(el: any, node: any) { throw 'not implemented'; }
|
||||
replaceChild(el: any, newNode: any, oldNode: any) { throw 'not implemented'; }
|
||||
remove(el: any): Node { throw 'not implemented'; }
|
||||
insertBefore(parent: any, el: any, node: any) { throw 'not implemented'; }
|
||||
insertAllBefore(parent: any, el: any, nodes: any) { throw 'not implemented'; }
|
||||
insertAfter(parent: any, el: any, node: any) { throw 'not implemented'; }
|
||||
setInnerHTML(el: any, value: any) { throw 'not implemented'; }
|
||||
getText(el: any): string { throw 'not implemented'; }
|
||||
setText(el: any, value: string) { throw 'not implemented'; }
|
||||
getValue(el: any): string { throw 'not implemented'; }
|
||||
setValue(el: any, value: string) { throw 'not implemented'; }
|
||||
getChecked(el: any): boolean { throw 'not implemented'; }
|
||||
setChecked(el: any, value: boolean) { throw 'not implemented'; }
|
||||
createComment(text: string): any { throw 'not implemented'; }
|
||||
createTemplate(html: any): HTMLElement { throw 'not implemented'; }
|
||||
createElement(tagName: any, doc?: any): HTMLElement { throw 'not implemented'; }
|
||||
createElementNS(ns: string, tagName: string, doc?: any): Element { throw 'not implemented'; }
|
||||
createTextNode(text: string, doc?: any): Text { throw 'not implemented'; }
|
||||
createScriptTag(attrName: string, attrValue: string, doc?: any): HTMLElement {
|
||||
throw 'not implemented';
|
||||
}
|
||||
createStyleElement(css: string, doc?: any): HTMLStyleElement { throw 'not implemented'; }
|
||||
createShadowRoot(el: any): any { throw 'not implemented'; }
|
||||
getShadowRoot(el: any): any { throw 'not implemented'; }
|
||||
getHost(el: any): any { throw 'not implemented'; }
|
||||
getDistributedNodes(el: any): Node[] { throw 'not implemented'; }
|
||||
clone(node: Node): Node { throw 'not implemented'; }
|
||||
getElementsByClassName(element: any, name: string): HTMLElement[] { throw 'not implemented'; }
|
||||
getElementsByTagName(element: any, name: string): HTMLElement[] { throw 'not implemented'; }
|
||||
classList(element: any): any[] { throw 'not implemented'; }
|
||||
addClass(element: any, className: string) { throw 'not implemented'; }
|
||||
|
@ -126,7 +112,6 @@ export class WorkerDomAdapter extends DomAdapter {
|
|||
templateAwareRoot(el: any) { throw 'not implemented'; }
|
||||
createHtmlDocument(): HTMLDocument { throw 'not implemented'; }
|
||||
getDefaultDocument(): Document { throw 'not implemented'; }
|
||||
getBoundingClientRect(el: any) { throw 'not implemented'; }
|
||||
getTitle(doc: Document): string { throw 'not implemented'; }
|
||||
setTitle(doc: Document, newTitle: string) { throw 'not implemented'; }
|
||||
elementMatches(n: any, selector: string): boolean { throw 'not implemented'; }
|
||||
|
@ -135,11 +120,8 @@ export class WorkerDomAdapter extends DomAdapter {
|
|||
isElementNode(node: any): boolean { throw 'not implemented'; }
|
||||
hasShadowRoot(node: any): boolean { throw 'not implemented'; }
|
||||
isShadowRoot(node: any): boolean { throw 'not implemented'; }
|
||||
importIntoDoc(node: Node): Node { throw 'not implemented'; }
|
||||
adoptNode(node: Node): Node { throw 'not implemented'; }
|
||||
getHref(element: any): string { throw 'not implemented'; }
|
||||
getEventKey(event: any): string { throw 'not implemented'; }
|
||||
resolveAndSetHref(element: any, baseUrl: string, href: string) { throw 'not implemented'; }
|
||||
supportsDOMEvents(): boolean { throw 'not implemented'; }
|
||||
supportsNativeShadowDOM(): boolean { throw 'not implemented'; }
|
||||
getGlobalEventTarget(doc: Document, target: string): any { throw 'not implemented'; }
|
||||
|
|
Loading…
Reference in New Issue