/** * @license * Copyright Google LLC 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 */ import {DOCUMENT} from '@angular/common'; import {inject, InjectionToken} from '@angular/core'; /** * Injection token used to inject the document into Directionality. * This is used so that the value can be faked in tests. * * We can't use the real document in tests because changing the real `dir` causes geometry-based * tests in Safari to fail. * * We also can't re-provide the DOCUMENT token from platform-brower because the unit tests * themselves use things like `querySelector` in test code. * * This token is defined in a separate file from Directionality as a workaround for * https://github.com/angular/angular/issues/22559 * * @docs-private */ export const DIR_DOCUMENT = new InjectionToken('cdk-dir-doc', { providedIn: 'root', factory: DIR_DOCUMENT_FACTORY, }); /** @docs-private */ export function DIR_DOCUMENT_FACTORY(): Document { return inject(DOCUMENT); }