chore: add const to UserContext.DEFAULT (#11846)

This commit is contained in:
jrandolf 2024-02-06 16:42:02 +01:00 committed by GitHub
parent 799058cc7b
commit b63ebc721d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 4 additions and 4 deletions

View File

@ -28,7 +28,7 @@ import {BrowsingContext, BrowsingContextEvent} from './BrowsingContext.js';
import type {BidiConnection} from './Connection.js'; import type {BidiConnection} from './Connection.js';
import type {Browser as BrowserCore} from './core/Browser.js'; import type {Browser as BrowserCore} from './core/Browser.js';
import {Session} from './core/Session.js'; import {Session} from './core/Session.js';
import type {UserContext} from './core/UserContext.js'; import {UserContext} from './core/UserContext.js';
import { import {
BiDiBrowserTarget, BiDiBrowserTarget,
BiDiBrowsingContextTarget, BiDiBrowsingContextTarget,
@ -181,7 +181,7 @@ export class BidiBrowser extends Browser {
); );
this.connection.registerBrowsingContexts(context); this.connection.registerBrowsingContexts(context);
const browserContext = const browserContext =
event.userContext === 'default' event.userContext === UserContext.DEFAULT
? this.defaultBrowserContext() ? this.defaultBrowserContext()
: this.browserContexts().find(browserContext => { : this.browserContexts().find(browserContext => {
return browserContext.id === event.userContext; return browserContext.id === event.userContext;

View File

@ -135,7 +135,7 @@ export class BidiBrowserContext extends BrowserContext {
} }
override get id(): string | undefined { override get id(): string | undefined {
if (this.#userContext.id === 'default') { if (this.#userContext.id === UserContext.DEFAULT) {
return undefined; return undefined;
} }
return this.#userContext.id; return this.#userContext.id;

View File

@ -43,7 +43,7 @@ export class UserContext extends EventEmitter<{
reason: string; reason: string;
}; };
}> { }> {
static DEFAULT = 'default'; static DEFAULT = 'default' as const;
static create(browser: Browser, id: string): UserContext { static create(browser: Browser, id: string): UserContext {
const context = new UserContext(browser, id); const context = new UserContext(browser, id);