refactor: Move dom_adapter.ts
to @angular/common
(#32154)
This work is needed in preparation for turning tokens into tree-shakable injectables. PR Close #32154
This commit is contained in:
@ -6,11 +6,9 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {ɵparseCookieValue as parseCookieValue} from '@angular/common';
|
||||
import {ɵparseCookieValue as parseCookieValue, ɵsetRootDomAdapter as setRootDomAdapter} from '@angular/common';
|
||||
import {ɵglobal as global} from '@angular/core';
|
||||
|
||||
import {setRootDomAdapter} from '../dom/dom_adapter';
|
||||
|
||||
import {GenericBrowserDomAdapter} from './generic_browser_adapter';
|
||||
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {DomAdapter} from '../dom/dom_adapter';
|
||||
import {ɵDomAdapter as DomAdapter} from '@angular/common';
|
||||
|
||||
|
||||
|
||||
|
@ -6,15 +6,11 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {DOCUMENT, LocationChangeListener, PlatformLocation} from '@angular/common';
|
||||
import {DOCUMENT, LocationChangeListener, PlatformLocation, ɵgetDOM as getDOM} from '@angular/common';
|
||||
import {Inject, Injectable} from '@angular/core';
|
||||
|
||||
import {getDOM} from '../../dom/dom_adapter';
|
||||
|
||||
import {supportsState} from './history';
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* `PlatformLocation` encapsulates all of the direct calls to platform APIs.
|
||||
* This class should not be used directly by an application developer. Instead, use
|
||||
|
@ -6,13 +6,9 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {DOCUMENT} from '@angular/common';
|
||||
import {DOCUMENT, ɵDomAdapter as DomAdapter, ɵgetDOM as getDOM} from '@angular/common';
|
||||
import {Inject, Injectable, ɵɵinject} from '@angular/core';
|
||||
|
||||
import {DomAdapter, getDOM} from '../dom/dom_adapter';
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Represents a meta element.
|
||||
*
|
||||
|
@ -6,11 +6,9 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {DOCUMENT} from '@angular/common';
|
||||
import {DOCUMENT, ɵgetDOM as getDOM} from '@angular/common';
|
||||
import {APP_INITIALIZER, ApplicationInitStatus, Inject, InjectionToken, Injector, StaticProvider} from '@angular/core';
|
||||
|
||||
import {getDOM} from '../dom/dom_adapter';
|
||||
|
||||
/**
|
||||
* An id that identifies a particular application being bootstrapped, that should
|
||||
* match across the client/server boundary.
|
||||
|
@ -6,10 +6,9 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {ɵgetDOM as getDOM} from '@angular/common';
|
||||
import {GetTestability, Testability, TestabilityRegistry, setTestabilityGetter, ɵglobal as global} from '@angular/core';
|
||||
|
||||
import {getDOM} from '../dom/dom_adapter';
|
||||
|
||||
export class BrowserGetTestability implements GetTestability {
|
||||
static init() { setTestabilityGetter(new BrowserGetTestability()); }
|
||||
|
||||
|
@ -6,10 +6,9 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {DOCUMENT} from '@angular/common';
|
||||
import {DOCUMENT, ɵgetDOM as getDOM} from '@angular/common';
|
||||
import {Inject, Injectable, ɵɵinject} from '@angular/core';
|
||||
|
||||
import {getDOM} from '../dom/dom_adapter';
|
||||
|
||||
/**
|
||||
* Factory to create Title service.
|
||||
|
@ -6,8 +6,8 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {ɵgetDOM as getDOM} from '@angular/common';
|
||||
import {ApplicationRef, ComponentRef} from '@angular/core';
|
||||
import {getDOM} from '../../dom/dom_adapter';
|
||||
import {window} from './browser';
|
||||
|
||||
export class ChangeDetectionPerfRecord {
|
||||
|
@ -6,8 +6,8 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {ɵgetDOM as getDOM} from '@angular/common';
|
||||
import {DebugElement, DebugNode, Predicate, Type} from '@angular/core';
|
||||
import {getDOM} from '../../dom/dom_adapter';
|
||||
|
||||
|
||||
|
||||
|
@ -1,110 +0,0 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright Google Inc. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by an MIT-style license that can be
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
|
||||
let _DOM: DomAdapter = null !;
|
||||
|
||||
export function getDOM() {
|
||||
return _DOM;
|
||||
}
|
||||
|
||||
export function setDOM(adapter: DomAdapter) {
|
||||
_DOM = adapter;
|
||||
}
|
||||
|
||||
export function setRootDomAdapter(adapter: DomAdapter) {
|
||||
if (!_DOM) {
|
||||
_DOM = adapter;
|
||||
}
|
||||
}
|
||||
|
||||
/* tslint:disable:requireParameterType */
|
||||
/**
|
||||
* Provides DOM operations in an environment-agnostic way.
|
||||
*
|
||||
* @security Tread carefully! Interacting with the DOM directly is dangerous and
|
||||
* can introduce XSS risks.
|
||||
*/
|
||||
export abstract class DomAdapter {
|
||||
// Needs Domino-friendly test utility
|
||||
abstract getProperty(el: Element, name: string): any;
|
||||
abstract dispatchEvent(el: any, evt: any): any;
|
||||
|
||||
// Used by router
|
||||
abstract log(error: any): any;
|
||||
abstract logGroup(error: any): any;
|
||||
abstract logGroupEnd(): any;
|
||||
|
||||
// Used by Meta
|
||||
abstract querySelectorAll(el: any, selector: string): any[];
|
||||
abstract remove(el: any): Node;
|
||||
abstract getAttribute(element: any, attribute: string): string|null;
|
||||
|
||||
// Used by platform-server
|
||||
abstract setProperty(el: Element, name: string, value: any): any;
|
||||
abstract querySelector(el: any, selector: string): any;
|
||||
abstract nextSibling(el: any): Node|null;
|
||||
abstract parentElement(el: any): Node|null;
|
||||
abstract clearNodes(el: any): any;
|
||||
abstract appendChild(el: any, node: any): any;
|
||||
abstract removeChild(el: any, node: any): any;
|
||||
abstract insertBefore(parent: any, ref: any, node: any): any;
|
||||
abstract setText(el: any, value: string): any;
|
||||
abstract createComment(text: string): any;
|
||||
abstract createElement(tagName: any, doc?: any): HTMLElement;
|
||||
abstract createElementNS(ns: string, tagName: string, doc?: any): Element;
|
||||
abstract createTextNode(text: string, doc?: any): Text;
|
||||
abstract getElementsByTagName(element: any, name: string): HTMLElement[];
|
||||
abstract addClass(element: any, className: string): any;
|
||||
abstract removeClass(element: any, className: string): any;
|
||||
abstract getStyle(element: any, styleName: string): any;
|
||||
abstract setStyle(element: any, styleName: string, styleValue: string): any;
|
||||
abstract removeStyle(element: any, styleName: string): any;
|
||||
abstract setAttribute(element: any, name: string, value: string): any;
|
||||
abstract setAttributeNS(element: any, ns: string, name: string, value: string): any;
|
||||
abstract removeAttribute(element: any, attribute: string): any;
|
||||
abstract removeAttributeNS(element: any, ns: string, attribute: string): any;
|
||||
abstract createHtmlDocument(): HTMLDocument;
|
||||
abstract getDefaultDocument(): Document;
|
||||
|
||||
// Used by Title
|
||||
abstract getTitle(doc: Document): string;
|
||||
abstract setTitle(doc: Document, newTitle: string): any;
|
||||
|
||||
// Used by By.css
|
||||
abstract elementMatches(n: any, selector: string): boolean;
|
||||
abstract isElementNode(node: any): boolean;
|
||||
|
||||
// Used by Testability
|
||||
abstract isShadowRoot(node: any): boolean;
|
||||
abstract getHost(el: any): any;
|
||||
|
||||
// Used by KeyEventsPlugin
|
||||
abstract onAndCancel(el: any, evt: any, listener: any): Function;
|
||||
abstract getEventKey(event: any): string;
|
||||
abstract supportsDOMEvents(): boolean;
|
||||
|
||||
// Used by PlatformLocation and ServerEventManagerPlugin
|
||||
abstract getGlobalEventTarget(doc: Document, target: string): any;
|
||||
|
||||
// Used by PlatformLocation
|
||||
abstract getHistory(): History;
|
||||
abstract getLocation(): Location;
|
||||
abstract getBaseHref(doc: Document): string|null;
|
||||
abstract resetBaseElement(): void;
|
||||
|
||||
// TODO: remove dependency in DefaultValueAccessor
|
||||
abstract getUserAgent(): string;
|
||||
|
||||
// Used by AngularProfiler
|
||||
abstract performanceNow(): number;
|
||||
|
||||
// Used by CookieXSRFStrategy
|
||||
abstract supportsCookies(): boolean;
|
||||
abstract getCookie(name: string): string|null;
|
||||
}
|
@ -6,10 +6,9 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {ɵgetDOM as getDOM} from '@angular/common';
|
||||
import {Inject, Injectable, InjectionToken, NgZone} from '@angular/core';
|
||||
|
||||
import {getDOM} from '../dom_adapter';
|
||||
|
||||
/**
|
||||
* The injection token for the event-manager plug-in service.
|
||||
*
|
||||
|
@ -6,11 +6,8 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {DOCUMENT} from '@angular/common';
|
||||
import {DOCUMENT, ɵgetDOM as getDOM} from '@angular/common';
|
||||
import {Inject, Injectable, NgZone} from '@angular/core';
|
||||
|
||||
import {getDOM} from '../dom_adapter';
|
||||
|
||||
import {EventManagerPlugin} from './event_manager';
|
||||
|
||||
/**
|
||||
|
@ -6,9 +6,8 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {DOCUMENT} from '@angular/common';
|
||||
import {DOCUMENT, ɵgetDOM as getDOM} from '@angular/common';
|
||||
import {Inject, Injectable, OnDestroy} from '@angular/core';
|
||||
import {getDOM} from './dom_adapter';
|
||||
|
||||
@Injectable()
|
||||
export class SharedStylesHost {
|
||||
|
@ -13,7 +13,6 @@ export {TRANSITION_ID as ɵTRANSITION_ID} from './browser/server-transition';
|
||||
export {BrowserGetTestability as ɵBrowserGetTestability} from './browser/testability';
|
||||
export {escapeHtml as ɵescapeHtml} from './browser/transfer_state';
|
||||
export {ELEMENT_PROBE_PROVIDERS as ɵELEMENT_PROBE_PROVIDERS} from './dom/debug/ng_probe';
|
||||
export {DomAdapter as ɵDomAdapter, getDOM as ɵgetDOM, setRootDomAdapter as ɵsetRootDomAdapter} from './dom/dom_adapter';
|
||||
export {DomRendererFactory2 as ɵDomRendererFactory2, NAMESPACE_URIS as ɵNAMESPACE_URIS, flattenStyles as ɵflattenStyles, shimContentAttribute as ɵshimContentAttribute, shimHostAttribute as ɵshimHostAttribute} from './dom/dom_renderer';
|
||||
export {DomEventsPlugin as ɵDomEventsPlugin} from './dom/events/dom_events';
|
||||
export {HammerGesturesPlugin as ɵHammerGesturesPlugin} from './dom/events/hammer_gestures';
|
||||
|
@ -6,7 +6,7 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {DOCUMENT, isPlatformBrowser} from '@angular/common';
|
||||
import {DOCUMENT, isPlatformBrowser, ɵgetDOM as getDOM} from '@angular/common';
|
||||
import {APP_INITIALIZER, CUSTOM_ELEMENTS_SCHEMA, Compiler, Component, Directive, ErrorHandler, Inject, Injector, Input, LOCALE_ID, NgModule, OnDestroy, PLATFORM_ID, PLATFORM_INITIALIZER, Pipe, Provider, Sanitizer, StaticProvider, Type, VERSION, createPlatformFactory} from '@angular/core';
|
||||
import {ApplicationRef, destroyPlatform} from '@angular/core/src/application_ref';
|
||||
import {Console} from '@angular/core/src/console';
|
||||
@ -15,7 +15,6 @@ import {Testability, TestabilityRegistry} from '@angular/core/src/testability/te
|
||||
import {AsyncTestCompleter, Log, afterEach, beforeEach, beforeEachProviders, describe, inject, it} from '@angular/core/testing/src/testing_internal';
|
||||
import {BrowserModule} from '@angular/platform-browser';
|
||||
import {platformBrowserDynamic} from '@angular/platform-browser-dynamic';
|
||||
import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter';
|
||||
import {expect} from '@angular/platform-browser/testing/src/matchers';
|
||||
import {ivyEnabled, modifiedInIvy, onlyInIvy} from '@angular/private/testing';
|
||||
|
||||
|
@ -6,10 +6,10 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {ɵgetDOM as getDOM} from '@angular/common';
|
||||
import {Injectable} from '@angular/core';
|
||||
import {TestBed} from '@angular/core/testing';
|
||||
import {BrowserModule, Meta} from '@angular/platform-browser';
|
||||
import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter';
|
||||
import {expect} from '@angular/platform-browser/testing/src/matchers';
|
||||
|
||||
{
|
||||
|
@ -6,10 +6,10 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {ɵgetDOM as getDOM} from '@angular/common';
|
||||
import {Injectable} from '@angular/core';
|
||||
import {TestBed} from '@angular/core/testing';
|
||||
import {BrowserModule, Title} from '@angular/platform-browser';
|
||||
import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter';
|
||||
import {expect} from '@angular/platform-browser/testing/src/matchers';
|
||||
|
||||
{
|
||||
|
@ -6,12 +6,11 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {ɵgetDOM as getDOM} from '@angular/common';
|
||||
import {NgZone} from '@angular/core/src/zone/ng_zone';
|
||||
import {beforeEach, describe, expect, it} from '@angular/core/testing/src/testing_internal';
|
||||
import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter';
|
||||
import {DomEventsPlugin} from '@angular/platform-browser/src/dom/events/dom_events';
|
||||
import {EventManager, EventManagerPlugin} from '@angular/platform-browser/src/dom/events/event_manager';
|
||||
|
||||
import {createMouseEvent, el} from '../../../testing/src/browser_util';
|
||||
|
||||
(function() {
|
||||
|
@ -6,8 +6,8 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {ɵgetDOM as getDOM} from '@angular/common';
|
||||
import {beforeEach, describe, it} from '@angular/core/testing/src/testing_internal';
|
||||
import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter';
|
||||
import {DomSharedStylesHost} from '@angular/platform-browser/src/dom/shared_styles_host';
|
||||
import {expect} from '@angular/platform-browser/testing/src/matchers';
|
||||
|
||||
|
@ -6,8 +6,8 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {ɵgetDOM as getDOM} from '@angular/common';
|
||||
import {NgZone, ɵglobal as global} from '@angular/core';
|
||||
import {ɵgetDOM as getDOM} from '@angular/platform-browser';
|
||||
|
||||
export let browserDetection: BrowserDetection;
|
||||
|
||||
|
@ -7,14 +7,13 @@
|
||||
*/
|
||||
|
||||
|
||||
import {ɵgetDOM as getDOM} from '@angular/common';
|
||||
import {Type, ɵglobal as global} from '@angular/core';
|
||||
import {ComponentFixture} from '@angular/core/testing';
|
||||
import {By, ɵgetDOM as getDOM} from '@angular/platform-browser';
|
||||
|
||||
import {By} from '@angular/platform-browser';
|
||||
import {childNodesAsList, hasClass, hasStyle, isCommentNode} from './browser_util';
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Jasmine matchers that check Angular specific conditions.
|
||||
*
|
||||
|
Reference in New Issue
Block a user