chore: don't use Object.freeze for internal properties (#10945)
This commit is contained in:
parent
3fc8da9955
commit
ce5461d0d5
@ -104,7 +104,7 @@ export class BidiPage extends Page {
|
||||
],
|
||||
['browsingContext.userPromptOpened', this.#onDialog.bind(this)],
|
||||
]);
|
||||
#networkManagerEvents = Object.freeze([
|
||||
readonly #networkManagerEvents = [
|
||||
[
|
||||
NetworkManagerEvent.Request,
|
||||
(request: BidiHTTPRequest) => {
|
||||
@ -135,9 +135,9 @@ export class BidiPage extends Page {
|
||||
this.emit(PageEvent.Response, response);
|
||||
},
|
||||
],
|
||||
] as const);
|
||||
] as const;
|
||||
|
||||
#browsingContextEvents = new Map<symbol, Handler<any>>([
|
||||
readonly #browsingContextEvents = new Map<symbol, Handler<any>>([
|
||||
[BrowsingContextEvent.Created, this.#onContextCreated.bind(this)],
|
||||
[BrowsingContextEvent.Destroyed, this.#onContextDestroyed.bind(this)],
|
||||
]);
|
||||
|
@ -44,11 +44,10 @@ interface ARIASelector {
|
||||
role?: string;
|
||||
}
|
||||
|
||||
const KNOWN_ATTRIBUTES = Object.freeze(['name', 'role']);
|
||||
const isKnownAttribute = (
|
||||
attribute: string
|
||||
): attribute is keyof ARIASelector => {
|
||||
return KNOWN_ATTRIBUTES.includes(attribute);
|
||||
return ['name', 'role'].includes(attribute);
|
||||
};
|
||||
|
||||
const normalizeValue = (value: string): string => {
|
||||
|
@ -113,7 +113,7 @@ export class NetworkManager extends EventEmitter<CdpNetworkManagerEvents> {
|
||||
#userAgent?: string;
|
||||
#userAgentMetadata?: Protocol.Emulation.UserAgentMetadata;
|
||||
|
||||
#handlers = Object.freeze([
|
||||
readonly #handlers = [
|
||||
['Fetch.requestPaused', this.#onRequestPaused],
|
||||
['Fetch.authRequired', this.#onAuthRequired],
|
||||
['Network.requestWillBeSent', this.#onRequestWillBeSent],
|
||||
@ -123,7 +123,7 @@ export class NetworkManager extends EventEmitter<CdpNetworkManagerEvents> {
|
||||
['Network.loadingFailed', this.#onLoadingFailed],
|
||||
['Network.responseReceivedExtraInfo', this.#onResponseReceivedExtraInfo],
|
||||
[CDPSessionEvent.Disconnected, this.#removeClient],
|
||||
] as const);
|
||||
] as const;
|
||||
|
||||
#clients = new Map<CDPSession, DisposableStack>();
|
||||
|
||||
|
@ -143,7 +143,7 @@ export class CdpPage extends Page {
|
||||
#serviceWorkerBypassed = false;
|
||||
#userDragInterceptionEnabled = false;
|
||||
|
||||
#frameManagerHandlers = Object.freeze([
|
||||
readonly #frameManagerHandlers = [
|
||||
[
|
||||
FrameManagerEvent.FrameAttached,
|
||||
(frame: CdpFrame) => {
|
||||
@ -162,9 +162,9 @@ export class CdpPage extends Page {
|
||||
this.emit(PageEvent.FrameNavigated, frame);
|
||||
},
|
||||
],
|
||||
] as const);
|
||||
] as const;
|
||||
|
||||
#networkManagerHandlers = Object.freeze([
|
||||
readonly #networkManagerHandlers = [
|
||||
[
|
||||
NetworkManagerEvent.Request,
|
||||
(request: HTTPRequest) => {
|
||||
@ -195,9 +195,9 @@ export class CdpPage extends Page {
|
||||
this.emit(PageEvent.RequestFinished, request);
|
||||
},
|
||||
],
|
||||
] as const);
|
||||
] as const;
|
||||
|
||||
#sessionHandlers = Object.freeze([
|
||||
readonly #sessionHandlers = [
|
||||
[
|
||||
CDPSessionEvent.Disconnected,
|
||||
() => {
|
||||
@ -226,7 +226,7 @@ export class CdpPage extends Page {
|
||||
['Performance.metrics', this.#emitMetrics.bind(this)],
|
||||
['Log.entryAdded', this.#onLogEntryAdded.bind(this)],
|
||||
['Page.fileChooserOpened', this.#onFileChooser.bind(this)],
|
||||
] as const);
|
||||
] as const;
|
||||
|
||||
constructor(
|
||||
client: CDPSession,
|
||||
|
@ -23,15 +23,12 @@ import type {QueryHandler} from './QueryHandler.js';
|
||||
import {TextQueryHandler} from './TextQueryHandler.js';
|
||||
import {XPathQueryHandler} from './XPathQueryHandler.js';
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export const BUILTIN_QUERY_HANDLERS = Object.freeze({
|
||||
const BUILTIN_QUERY_HANDLERS = {
|
||||
aria: ARIAQueryHandler,
|
||||
pierce: PierceQueryHandler,
|
||||
xpath: XPathQueryHandler,
|
||||
text: TextQueryHandler,
|
||||
});
|
||||
} as const;
|
||||
|
||||
const QUERY_SEPARATORS = ['=', '/'];
|
||||
|
||||
@ -42,7 +39,7 @@ export function getQueryHandlerByName(
|
||||
name: string
|
||||
): typeof QueryHandler | undefined {
|
||||
if (name in BUILTIN_QUERY_HANDLERS) {
|
||||
return BUILTIN_QUERY_HANDLERS[name as 'aria'];
|
||||
return BUILTIN_QUERY_HANDLERS[name as keyof typeof BUILTIN_QUERY_HANDLERS];
|
||||
}
|
||||
return customQueryHandlers.get(name);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user