Skip to content

Commit 7ccec14

Browse files
crisbetothePunderWoman
authored andcommitted
feat(core): move DOCUMENT token into core (#60663)
Moves the `DOCUMENT` token from `common` into `core` since it's relevant for lots of SSR use cases and users shouldn't have to install `common` for it. The token is still exported through `common` for backwards compatibility. PR Close #60663
1 parent 4f5216e commit 7ccec14

12 files changed

Lines changed: 31 additions & 17 deletions

File tree

goldens/public-api/common/index.api.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
import { ChangeDetectorRef } from '@angular/core';
88
import { DoCheck } from '@angular/core';
9+
import { DOCUMENT } from '@angular/core';
910
import { ElementRef } from '@angular/core';
1011
import * as i0 from '@angular/core';
1112
import { ɵIMAGE_CONFIG as IMAGE_CONFIG } from '@angular/core';
@@ -163,8 +164,7 @@ export class DecimalPipe implements PipeTransform {
163164
static ɵpipe: i0.ɵɵPipeDeclaration<DecimalPipe, "number", true>;
164165
}
165166

166-
// @public
167-
export const DOCUMENT: InjectionToken<Document>;
167+
export { DOCUMENT }
168168

169169
// @public
170170
export function formatCurrency(value: number, locale: string, currency: string, currencyCode?: string, digitsInfo?: string): string;

goldens/public-api/core/index.api.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -648,6 +648,9 @@ export interface DoCheck {
648648
ngDoCheck(): void;
649649
}
650650

651+
// @public
652+
export const DOCUMENT: InjectionToken<Document>;
653+
651654
// @public
652655
export function effect(effectFn: (onCleanup: EffectCleanupRegisterFn) => void, options?: CreateEffectOptions): EffectRef;
653656

packages/common/src/common.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ export {
6666
NgTemplateOutlet,
6767
NgComponentOutlet,
6868
} from './directives/index';
69-
export {DOCUMENT} from './dom_tokens';
7069
export {
7170
AsyncPipe,
7271
DatePipe,
@@ -111,3 +110,6 @@ export {
111110
provideNetlifyLoader,
112111
} from './directives/ng_optimized_image';
113112
export {normalizeQueryParams as ɵnormalizeQueryParams} from './location/util';
113+
114+
// Backwards compatibility re-export.
115+
export {DOCUMENT} from '@angular/core';

packages/common/src/directives/ng_optimized_image/lcp_image_observer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ import {
1212
OnDestroy,
1313
ɵformatRuntimeError as formatRuntimeError,
1414
PLATFORM_ID,
15+
DOCUMENT,
1516
} from '@angular/core';
1617

17-
import {DOCUMENT} from '../../dom_tokens';
1818
import {RuntimeErrorCode} from '../../errors';
1919

2020
import {assertDevMode} from './asserts';

packages/common/src/directives/ng_optimized_image/preconnect_link_checker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ import {
1111
Injectable,
1212
InjectionToken,
1313
ɵformatRuntimeError as formatRuntimeError,
14+
DOCUMENT,
1415
} from '@angular/core';
1516

16-
import {DOCUMENT} from '../../dom_tokens';
1717
import {RuntimeErrorCode} from '../../errors';
1818

1919
import {assertDevMode} from './asserts';

packages/common/src/directives/ng_optimized_image/preload-link-creator.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,14 @@
66
* found in the LICENSE file at https://angular.dev/license
77
*/
88

9-
import {inject, Injectable, Renderer2, ɵRuntimeError as RuntimeError} from '@angular/core';
9+
import {
10+
inject,
11+
Injectable,
12+
Renderer2,
13+
ɵRuntimeError as RuntimeError,
14+
DOCUMENT,
15+
} from '@angular/core';
1016

11-
import {DOCUMENT} from '../../dom_tokens';
1217
import {RuntimeErrorCode} from '../../errors';
1318

1419
import {DEFAULT_PRELOADED_IMAGES_LIMIT, PRELOADED_IMAGES} from './tokens';

packages/common/src/location/location_strategy.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,15 @@
66
* found in the LICENSE file at https://angular.dev/license
77
*/
88

9-
import {Inject, inject, Injectable, InjectionToken, OnDestroy, Optional} from '@angular/core';
10-
11-
import {DOCUMENT} from '../dom_tokens';
9+
import {
10+
Inject,
11+
inject,
12+
Injectable,
13+
InjectionToken,
14+
OnDestroy,
15+
Optional,
16+
DOCUMENT,
17+
} from '@angular/core';
1218

1319
import {LocationChangeListener, PlatformLocation} from './platform_location';
1420
import {joinWithSlash, normalizeQueryParams} from './util';

packages/common/src/location/platform_location.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,9 @@
66
* found in the LICENSE file at https://angular.dev/license
77
*/
88

9-
import {inject, Injectable, InjectionToken} from '@angular/core';
9+
import {inject, Injectable, InjectionToken, DOCUMENT} from '@angular/core';
1010

1111
import {getDOM} from '../dom_adapter';
12-
import {DOCUMENT} from '../dom_tokens';
1312

1413
/**
1514
* This class should not be used directly by an application developer. Instead, use

packages/common/src/viewport_scroller.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@
66
* found in the LICENSE file at https://angular.dev/license
77
*/
88

9-
import {inject, ɵɵdefineInjectable} from '@angular/core';
10-
11-
import {DOCUMENT} from './dom_tokens';
9+
import {inject, ɵɵdefineInjectable, DOCUMENT} from '@angular/core';
1210

1311
/**
1412
* Defines a scroll position manager. Implemented by `BrowserViewportScroller`.

packages/core/src/core.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ export {ApplicationConfig, mergeApplicationConfig} from './application/applicati
117117
export {makeStateKey, StateKey, TransferState} from './transfer_state';
118118
export {booleanAttribute, numberAttribute} from './util/coercion';
119119
export {REQUEST, REQUEST_CONTEXT, RESPONSE_INIT} from './application/platform_tokens';
120+
export {DOCUMENT} from './document';
120121

121122
import {global} from './util/global';
122123
if (typeof ngDevMode !== 'undefined' && ngDevMode) {

0 commit comments

Comments
 (0)