Bug 1622996 - Refactor devtools codebase to use optional chaining (automated changes). r=jdescottes

Depends on D67084

Differential Revision: https://phabricator.services.mozilla.com/D67537
This commit is contained in:
Jason Laster
2020-03-19 21:13:38 +00:00
parent 57fded74c7
commit 3694ec93d0
153 changed files with 311 additions and 395 deletions

View File

@@ -465,8 +465,7 @@ function updateRemoteRuntimes(runtimes, type) {
runtimes.forEach(runtime => {
const existingRuntime = findRuntimeById(runtime.id, getState().runtimes);
const isConnectionValid =
existingRuntime &&
existingRuntime.runtimeDetails &&
existingRuntime?.runtimeDetails &&
!existingRuntime.runtimeDetails.clientWrapper.isClosed();
runtime.runtimeDetails = isConnectionValid
? existingRuntime.runtimeDetails

View File

@@ -99,7 +99,7 @@ class App extends PureComponent {
...this.props.usbRuntimes,
];
const runtime = runtimes.find(x => x.id === id);
return runtime && runtime.runtimeDetails;
return runtime?.runtimeDetails;
};
const { dispatch } = this.props;

View File

@@ -69,9 +69,9 @@ function getRuntimeEventExtras(runtime) {
const { extra, runtimeDetails } = runtime;
// deviceName can be undefined for non-usb devices, but we should not log "undefined".
const deviceName = (extra && extra.deviceName) || "";
const deviceName = extra?.deviceName || "";
const runtimeShortName = runtime.type === RUNTIMES.USB ? runtime.name : "";
const runtimeName = (runtimeDetails && runtimeDetails.info.name) || "";
const runtimeName = runtimeDetails?.info.name || "";
return {
connection_type: runtime.type,
device_name: deviceName,
@@ -136,8 +136,7 @@ function onRemoteRuntimesUpdated(action, store) {
const oldRuntime = oldRuntimes.find(
r => r.extra.deviceName === oldDeviceName
);
const isUnplugged =
newRuntime && newRuntime.isUnplugged && !oldRuntime.isUnplugged;
const isUnplugged = newRuntime?.isUnplugged && !oldRuntime.isUnplugged;
if (oldDeviceName && (!newRuntime || isUnplugged)) {
recordEvent("device_removed", {
connection_type: action.runtimeType,
@@ -164,8 +163,7 @@ function onRemoteRuntimesUpdated(action, store) {
const oldRuntime = oldRuntimes.find(
r => r.extra.deviceName === newDeviceName
);
const isPlugged =
oldRuntime && oldRuntime.isUnplugged && !newRuntime.isUnplugged;
const isPlugged = oldRuntime?.isUnplugged && !newRuntime.isUnplugged;
if (newDeviceName && (!oldRuntime || isPlugged)) {
recordEvent("device_added", {

View File

@@ -38,7 +38,7 @@ function accessibles(state = getInitialState(), action) {
}
function getActorID(accessible) {
return accessible.actorID || (accessible._form && accessible._form.actor);
return accessible.actorID || accessible._form?.actor;
}
/**

View File

@@ -9183,7 +9183,11 @@ function getSpecifiers(specifiers) {
return [];
}
return specifiers.map(specifier => specifier.local && specifier.local.name);
return specifiers.map(specifier => {
var _specifier$local;
return (_specifier$local = specifier.local) === null || _specifier$local === void 0 ? void 0 : _specifier$local.name;
});
}
function isComputedExpression(expression) {
@@ -9226,10 +9230,14 @@ function getVariables(dec) {
// e.g. const [{a, b }] = 2
return dec.id.elements.filter(element => element).map(element => ({
name: t.isAssignmentPattern(element) ? element.left.name : element.name || element.argument && element.argument.name,
location: element.loc
})).filter(({
return dec.id.elements.filter(element => element).map(element => {
var _element$argument;
return {
name: t.isAssignmentPattern(element) ? element.left.name : element.name || ((_element$argument = element.argument) === null || _element$argument === void 0 ? void 0 : _element$argument.name),
location: element.loc
};
}).filter(({
name
}) => name);
}
@@ -15823,11 +15831,13 @@ function extractSymbols(sourceId) {
}
function extendSnippet(name, expression, path, prevPath) {
const computed = path && path.node.computed;
const prevComputed = prevPath && prevPath.node.computed;
var _path$node$property, _path$node$property$e;
const computed = path === null || path === void 0 ? void 0 : path.node.computed;
const prevComputed = prevPath === null || prevPath === void 0 ? void 0 : prevPath.node.computed;
const prevArray = t.isArrayExpression(prevPath);
const array = t.isArrayExpression(path);
const value = path && path.node.property && path.node.property.extra && path.node.property.extra.raw || "";
const value = (path === null || path === void 0 ? void 0 : (_path$node$property = path.node.property) === null || _path$node$property === void 0 ? void 0 : (_path$node$property$e = _path$node$property.extra) === null || _path$node$property$e === void 0 ? void 0 : _path$node$property$e.raw) || "";
if (expression === "") {
if (computed) {
@@ -15885,6 +15895,8 @@ function getMemberSnippet(node, expression = "") {
}
function getObjectSnippet(path, prevPath, expression = "") {
var _path$parentPath;
if (!path) {
return expression;
}
@@ -15892,11 +15904,13 @@ function getObjectSnippet(path, prevPath, expression = "") {
const name = path.node.key.name;
const extendedExpression = extendSnippet(name, expression, path, prevPath);
const nextPrevPath = path;
const nextPath = path.parentPath && path.parentPath.parentPath;
const nextPath = (_path$parentPath = path.parentPath) === null || _path$parentPath === void 0 ? void 0 : _path$parentPath.parentPath;
return getSnippet(nextPath, nextPrevPath, extendedExpression);
}
function getArraySnippet(path, prevPath, expression) {
var _path$parentPath2;
if (!prevPath.parentPath) {
throw new Error("Assertion failure - path should exist");
}
@@ -15904,7 +15918,7 @@ function getArraySnippet(path, prevPath, expression) {
const index = `${prevPath.parentPath.containerIndex}`;
const extendedExpression = extendSnippet(index, expression, path, prevPath);
const nextPrevPath = path;
const nextPath = path.parentPath && path.parentPath.parentPath;
const nextPath = (_path$parentPath2 = path.parentPath) === null || _path$parentPath2 === void 0 ? void 0 : _path$parentPath2.parentPath;
return getSnippet(nextPath, nextPrevPath, extendedExpression);
}
@@ -15950,7 +15964,7 @@ function getSnippet(path, prevPath, expression = "") {
}
if (t.isObjectExpression(path)) {
const parentPath = prevPath && prevPath.parentPath;
const parentPath = prevPath === null || prevPath === void 0 ? void 0 : prevPath.parentPath;
return getObjectSnippet(parentPath, prevPath, expression);
}
@@ -42490,8 +42504,6 @@ Object.defineProperty(exports, "__esModule", {
});
exports.default = void 0;
var _get = _interopRequireDefault(__webpack_require__(161));
var _findIndex = _interopRequireDefault(__webpack_require__(354));
var _findLastIndex = _interopRequireDefault(__webpack_require__(371));
@@ -42523,11 +42535,13 @@ function findSymbols(source) {
function getLocation(func) {
var _func$identifier, _func$identifier$loc;
const location = { ...func.location
}; // if the function has an identifier, start the block after it so the
// identifier is included in the "scope" of its parent
const identifierEnd = (0, _get.default)(func, "identifier.loc.end");
const identifierEnd = func === null || func === void 0 ? void 0 : (_func$identifier = func.identifier) === null || _func$identifier === void 0 ? void 0 : (_func$identifier$loc = _func$identifier.loc) === null || _func$identifier$loc === void 0 ? void 0 : _func$identifier$loc.end;
if (identifierEnd) {
location.start = identifierEnd;

View File

@@ -42,7 +42,7 @@ async function findBreakpointPosition(
);
const position = findPosition(positions, location);
return position && position.generatedLocation;
return position?.generatedLocation;
}
async function findNewLocation(

View File

@@ -56,8 +56,7 @@ export function generateInlinePreview(cx: ThreadContext, frame: ?Frame) {
);
let scopes: ?OriginalScope | Scope | null =
(originalFrameScopes && originalFrameScopes.scope) ||
(generatedFrameScopes && generatedFrameScopes.scope);
originalFrameScopes?.scope || generatedFrameScopes?.scope;
if (!scopes || !scopes.bindings) {
return;
@@ -145,8 +144,7 @@ function getBindingValues(
): Array<Preview> {
const previews = [];
const binding =
originalAstScopes[curLevel] && originalAstScopes[curLevel].bindings[name];
const binding = originalAstScopes[curLevel]?.bindings[name];
if (!binding) {
return previews;
}
@@ -212,13 +210,9 @@ function getExpressionNameAndValue(
const property: Object = properties.find(
prop => prop.name === meta.property
);
displayValue = property && property.contents.value;
displayValue = property?.contents.value;
displayName += `.${meta.property}`;
} else if (
displayValue &&
displayValue.preview &&
displayValue.preview.ownProperties
) {
} else if (displayValue?.preview?.ownProperties) {
const { ownProperties } = displayValue.preview;
Object.keys(ownProperties).forEach(prop => {
if (prop === meta.property) {

View File

@@ -24,7 +24,7 @@ import SourceMaps, { isGeneratedId } from "devtools-source-map";
function isFrameBlackboxed(state, frame) {
const source = getSource(state, frame.location.sourceId);
return source && source.isBlackBoxed;
return source?.isBlackBoxed;
}
function getSelectedFrameId(state, thread, frames) {
@@ -34,7 +34,7 @@ function getSelectedFrameId(state, thread, frames) {
}
selectedFrame = frames.find(frame => !isFrameBlackboxed(state, frame));
return selectedFrame && selectedFrame.id;
return selectedFrame?.id;
}
export function updateFrameLocation(
@@ -105,7 +105,7 @@ function isWasmOriginalSourceFrame(frame, getState: () => State): boolean {
frame.generatedLocation.sourceId
);
return Boolean(generatedSource && generatedSource.isWasm);
return Boolean(generatedSource?.isWasm);
}
async function expandFrames(

View File

@@ -193,8 +193,8 @@ describe("pause", () => {
},
},
},
mappings: { "1": null },
original: { "1": { pending: false, scope: null } },
mappings: { "1": undefined },
original: { "1": { pending: false, scope: undefined } },
});
expect(

View File

@@ -28,7 +28,7 @@ function cloneAction(action: any) {
action = { ...action };
// ADD_TAB, ...
if (action.source && action.source.text) {
if (action.source?.text) {
const source = { ...action.source, text: "" };
action.source = source;
}
@@ -46,7 +46,7 @@ function cloneAction(action: any) {
action.text = "";
}
if (action.value && action.value.text) {
if (action.value?.text) {
const value = { ...action.value, text: "" };
action.value = value;
}
@@ -76,7 +76,7 @@ function serializeAction(action) {
const serializer = function(key, value) {
// Serialize Object/LongString fronts
if (value && value.getGrip) {
if (value?.getGrip) {
return value.getGrip();
}
return value;

View File

@@ -9,15 +9,13 @@
* will appear in performance tooling under the User Timing API
*/
const mark =
window.performance && window.performance.mark
? window.performance.mark.bind(window.performance)
: a => {};
const mark = window.performance?.mark
? window.performance.mark.bind(window.performance)
: a => {};
const measure =
window.performance && window.performance.measure
? window.performance.measure.bind(window.performance)
: (a, b, c) => {};
const measure = window.performance?.measure
? window.performance.measure.bind(window.performance)
: (a, b, c) => {};
export function timing(store: any) {
return (next: any) => (action: any) => {

View File

@@ -36,9 +36,9 @@ function makeBookmark({ breakpoint }, { onClick, onContextMenu }) {
const bp = breakpointButton.cloneNode(true);
const isActive = breakpoint && !breakpoint.disabled;
const isDisabled = breakpoint && breakpoint.disabled;
const condition = breakpoint && breakpoint.options.condition;
const logValue = breakpoint && breakpoint.options.logValue;
const isDisabled = breakpoint?.disabled;
const condition = breakpoint?.options.condition;
const logValue = breakpoint?.options.logValue;
bp.className = classnames("column-breakpoint", {
"has-condition": condition,

View File

@@ -203,7 +203,7 @@ export class ConditionalPanel extends PureComponent<Props> {
getDefaultValue() {
const { breakpoint, log } = this.props;
const options = (breakpoint && breakpoint.options) || {};
const options = breakpoint?.options || {};
return log ? options.logValue : options.condition;
}

View File

@@ -137,7 +137,7 @@ export class DebugLine extends PureComponent<Props> {
const mapStateToProps = state => {
const frame = getVisibleSelectedFrame(state);
const previewLocation = getPausePreviewLocation(state);
const location = previewLocation || (frame && frame.location);
const location = previewLocation || frame?.location;
return {
frame,
location,

View File

@@ -134,7 +134,7 @@ class SourceFooter extends PureComponent<Props, State> {
blackBoxButton() {
const { cx, selectedSource, toggleBlackBox } = this.props;
const sourceLoaded = selectedSource && selectedSource.content;
const sourceLoaded = selectedSource?.content;
if (!selectedSource) {
return;

View File

@@ -225,10 +225,7 @@ export class Popup extends Component<Props> {
editorRef,
} = this.props;
if (
typeof resultGrip == "undefined" ||
(resultGrip && resultGrip.optimizedOut)
) {
if (typeof resultGrip == "undefined" || resultGrip?.optimizedOut) {
return null;
}

View File

@@ -262,7 +262,7 @@ class SearchBar extends Component<Props, State> {
function SearchModBtn({ modVal, className, svgName, tooltip }) {
const preppedClass = classnames(className, {
active: modifiers && modifiers[modVal],
active: modifiers?.[modVal],
});
return (
<button

View File

@@ -466,7 +466,7 @@ class Editor extends PureComponent<Props, State> {
}
// if user clicks gutter to set breakpoint on blackboxed source, un-blackbox the source.
if (selectedSource && selectedSource.isBlackBoxed) {
if (selectedSource?.isBlackBoxed) {
toggleBlackBox(cx, selectedSource);
}
@@ -689,7 +689,7 @@ class Editor extends PureComponent<Props, State> {
return (
<div
className={classnames("editor-wrapper", {
blackboxed: selectedSource && selectedSource.isBlackBoxed,
blackboxed: selectedSource?.isBlackBoxed,
"skip-pausing": skipPausing,
})}
ref={c => (this.$editorWrapper = c)}

View File

@@ -273,7 +273,7 @@ class SourceTreeItem extends Component<Props, State> {
return <AccessibleImage className="folder" />;
}
if (source && source.isBlackBoxed) {
if (source?.isBlackBoxed) {
return <AccessibleImage className="blackBox" />;
}

View File

@@ -129,7 +129,7 @@ class Breakpoint extends PureComponent<Props> {
const { source } = this.props;
const { column, line } = this.selectedLocation;
const isWasm = source && source.isWasm;
const isWasm = source?.isWasm;
const columnVal = features.columnBreakpoints && column ? `:${column}` : "";
const bpLocation = isWasm
? `0x${line.toString(16).toUpperCase()}`

View File

@@ -272,18 +272,14 @@ const mapStateToProps = state => {
} = getOriginalFrameScope(
state,
cx.thread,
selectedSource && selectedSource.id,
selectedFrame && selectedFrame.id
selectedSource?.id,
selectedFrame?.id
) || { scope: null, pending: false };
const {
scope: generatedFrameScopes,
pending: generatedPending,
} = getGeneratedFrameScope(
state,
cx.thread,
selectedFrame && selectedFrame.id
) || {
} = getGeneratedFrameScope(state, cx.thread, selectedFrame?.id) || {
scope: null,
pending: false,
};

View File

@@ -249,7 +249,7 @@ class SecondaryPanes extends Component<Props, State> {
if (
!selectedFrame ||
isGeneratedId(selectedFrame.location.sourceId) ||
(source && source.isPrettyPrinted)
source?.isPrettyPrinted
) {
return null;
}

View File

@@ -84,7 +84,7 @@ class ManagedTree extends Component<Props, State> {
while (parents.length) {
const children = [];
for (const parent of parents) {
if (parent.contents && parent.contents.length) {
if (parent.contents?.length) {
for (const child of parent.contents) {
expandItem(child);
children.push(child);

View File

@@ -239,7 +239,7 @@ export function hasLogpoint(
location: ?SourceLocation
): ?string {
const breakpoint = getBreakpoint(state, location);
return breakpoint && breakpoint.options.logValue;
return breakpoint?.options.logValue;
}
export default update;

View File

@@ -254,13 +254,13 @@ function update(
...threadState().frameScopes.original,
[selectedFrameId]: {
pending: status !== "done",
scope: value && value.scope,
scope: value?.scope,
},
};
const mappings = {
...threadState().frameScopes.mappings,
[selectedFrameId]: value && value.mappings,
[selectedFrameId]: value?.mappings,
};
return updateThreadState({
@@ -417,7 +417,7 @@ function getPauseLocation(state, action) {
return null;
}
const frame = frames && frames[0];
const frame = frames?.[0];
if (!frame) {
return previousLocation;
}
@@ -635,7 +635,7 @@ export function getSelectedFrameId(state: State, thread: ThreadId) {
export function getTopFrame(state: State, thread: ThreadId) {
const frames = getFrames(state, thread);
return frames && frames[0];
return frames?.[0];
}
export function getSkipPausing(state: State) {
@@ -680,7 +680,7 @@ export function getInlinePreviewExpression(
const previews = getThreadPauseState(state.pause, thread).inlinePreview[
getGeneratedFrameId(frameId)
];
return previews && previews[line] && previews[line][expression];
return previews?.[line]?.[expression];
}
// NOTE: currently only used for chrome

View File

@@ -797,7 +797,7 @@ export function getSourceContent(
export function getSelectedSourceId(state: OuterState) {
const source = getSelectedSource((state: any));
return source && source.id;
return source?.id;
}
export function getProjectDirectoryRoot(state: OuterState): string {
@@ -979,7 +979,7 @@ export function getBreakpointPositionsForSource(
sourceId: string
): ?BreakpointPositions {
const positions = getBreakpointPositions(state);
return positions && positions[sourceId];
return positions?.[sourceId];
}
export function hasBreakpointPositions(
@@ -995,7 +995,7 @@ export function getBreakpointPositionsForLine(
line: number
): ?Array<BreakpointPosition> {
const positions = getBreakpointPositionsForSource(state, sourceId);
return positions && positions[line];
return positions?.[line];
}
export function hasBreakpointPositionsForLine(

View File

@@ -118,7 +118,7 @@ export function startsWithThreadActor(state: State, path: string) {
const threadActors = getAllThreads(state).map(t => t.actor);
const match = path.match(new RegExp(`(${threadActors.join("|")})\/(.*)`));
return match && match[1];
return match?.[1];
}
type OuterState = { threads: ThreadsState };

View File

@@ -12,7 +12,6 @@ import {
import { getCurrentThreadFrames } from "../reducers/pause";
import { annotateFrames } from "../utils/pause/frames";
import { isOriginal } from "../utils/source";
import { get } from "lodash";
import type { State, SourceResourceState } from "../reducers/types";
import type { Frame, Source } from "../types";
import { createSelector } from "reselect";
@@ -57,7 +56,7 @@ export function formatCallStackFrames(
const formattedFrames: Frame[] = frames
.filter(frame => getSourceForFrame(sources, frame))
.map(frame => appendSource(sources, frame, selectedSource))
.filter(frame => !get(frame, "source.isBlackBoxed"));
.filter(frame => !frame?.source?.isBlackBoxed);
return annotateFrames(formattedFrames);
}

View File

@@ -70,7 +70,7 @@ function groupBreakpoints(breakpoints, selectedSource) {
function findBreakpoint(location, breakpointMap) {
const { line, column } = location;
const breakpoints = breakpointMap[line] && breakpointMap[line][column];
const breakpoints = breakpointMap[line]?.[column];
if (breakpoints) {
return breakpoints[0];

View File

@@ -48,7 +48,7 @@ function bindSelectors(obj: Object): Object {
function getCM() {
const cm: any = document.querySelector(".CodeMirror");
return cm && cm.CodeMirror;
return cm?.CodeMirror;
}
function formatMappedLocation(mappedLocation) {

View File

@@ -4,7 +4,7 @@
// @flow
import { get, findIndex } from "lodash";
import { findIndex } from "lodash";
// eslint-disable-next-line max-len
import type { Frame } from "../../../types";
@@ -49,7 +49,7 @@ export function collapseFrames(frames: Frame[]): GroupedFrames {
let currentGroup = null;
let prevItem = null;
for (const frame of frames) {
const prevLibrary = get(prevItem, "library");
const prevLibrary = prevItem?.library;
if (!currentGroup) {
currentGroup = [frame];

View File

@@ -67,10 +67,7 @@ const displayNameMap = {
function mapDisplayNames(frame, library) {
const { displayName } = frame;
return (
(displayNameMap[library] && displayNameMap[library][displayName]) ||
displayName
);
return displayNameMap[library]?.[displayName] || displayName;
}
function getFrameDisplayName(frame: Frame): string {

View File

@@ -4,10 +4,8 @@
// @flow
import { get } from "lodash";
import type { Frame } from "../../../types";
export function getFrameUrl(frame: Frame) {
return get(frame, "source.url", "") || "";
return frame?.source?.url ?? "";
}

View File

@@ -94,7 +94,7 @@ export function buildGeneratedBindingList(
desc: () => Promise.resolve(bindings[name]),
});
} else {
const globalGrip = globalScope && globalScope.object;
const globalGrip = globalScope?.object;
if (globalGrip) {
// Should always exist, just checking to keep Flow happy.

View File

@@ -260,7 +260,7 @@ async function mapImportReferenceToDescriptor({
for (
let op = meta, index = 0;
op && mappingContains(range, op) && desc && index < 2;
index++, op = op && op.parent
index++, op = op?.parent
) {
// Calling could potentially trigger side-effects, which would not
// be ideal for this case.

View File

@@ -178,7 +178,7 @@ function isReliableScope(scope: OriginalScope): boolean {
let unknownBindings = 0;
for (let s = scope; s; s = s.parent) {
const vars = (s.bindings && s.bindings.variables) || {};
const vars = s.bindings?.variables || {};
for (const key of Object.keys(vars)) {
const binding = vars[key];
@@ -452,7 +452,7 @@ async function findGeneratedBinding(
// because it can have multiple bindings, but we do want to make sure
// that all of the bindings that match the range are part of the same
// import declaration.
if (declRange && declRange.singleDeclaration) {
if (declRange?.singleDeclaration) {
const applicableDeclBindings = await loadApplicableBindings(
pos.declaration,
pos.type

View File

@@ -84,7 +84,7 @@ export function getScope(
}
}
if (vars && vars.length) {
if (vars?.length) {
const title = getScopeTitle(type, scope) || "";
vars.sort((a, b) => a.name.localeCompare(b.name));
return {

View File

@@ -46,11 +46,11 @@ export function getPauseReason(why?: ?Why): string | null {
}
export function isException(why: Why) {
return why && why.type && why.type === "exception";
return why?.type === "exception";
}
export function isInterrupted(why: ?Why) {
return why && why.type && why.type === "interrupted";
return why?.type === "interrupted";
}
export function inDebuggerEval(why: ?Why) {

View File

@@ -18,7 +18,7 @@ export function isVisible() {
export function getLineNumberWidth(editor: Object) {
const gutters = editor.display.gutters;
const lineNumbers = gutters.querySelector(".CodeMirror-linenumbers");
return lineNumbers && lineNumbers.clientWidth;
return lineNumbers?.clientWidth;
}
/**

View File

@@ -6,7 +6,6 @@
import type { AstLocation, AstPosition } from "./types";
import get from "lodash/get";
import findIndex from "lodash/findIndex";
import findLastIndex from "lodash/findLastIndex";
@@ -30,7 +29,7 @@ function getLocation(func) {
// if the function has an identifier, start the block after it so the
// identifier is included in the "scope" of its parent
const identifierEnd = get(func, "identifier.loc.end");
const identifierEnd = func?.identifier?.loc?.end;
if (identifierEnd) {
location.start = identifierEnd;
}

View File

@@ -311,16 +311,11 @@ function extendSnippet(
path?: { node: Node },
prevPath?: SimplePath
) {
const computed = path && path.node.computed;
const prevComputed = prevPath && prevPath.node.computed;
const computed = path?.node.computed;
const prevComputed = prevPath?.node.computed;
const prevArray = t.isArrayExpression(prevPath);
const array = t.isArrayExpression(path);
const value =
(path &&
path.node.property &&
path.node.property.extra &&
path.node.property.extra.raw) ||
"";
const value = path?.node.property?.extra?.raw || "";
if (expression === "") {
if (computed) {
@@ -460,7 +455,7 @@ function getSnippet(
}
if (t.isObjectExpression(path)) {
const parentPath = prevPath && prevPath.parentPath;
const parentPath = prevPath?.parentPath;
return getObjectSnippet(parentPath, prevPath, expression);
}

View File

@@ -80,7 +80,7 @@ export function getSpecifiers(specifiers: any) {
return [];
}
return specifiers.map(specifier => specifier.local && specifier.local.name);
return specifiers.map(specifier => specifier.local?.name);
}
export function isComputedExpression(expression: string): boolean {
@@ -127,7 +127,7 @@ export function getVariables(dec: Node) {
.map(element => ({
name: t.isAssignmentPattern(element)
? element.left.name
: element.name || (element.argument && element.argument.name),
: element.name || element.argument?.name,
location: element.loc,
}))
.filter(({ name }) => name);

View File

@@ -124,7 +124,7 @@ class DomTree extends Component {
});
// Object can be an objectFront, while Rep always expect grips.
if (props && props.object && props.object.getGrip) {
if (props?.object?.getGrip) {
repProps.object = props.object.getGrip();
}

View File

@@ -49,7 +49,7 @@ GripProvider.prototype = {
if (!value) {
return false;
}
const grip = value && value.getGrip ? value.getGrip() : value;
const grip = value?.getGrip ? value.getGrip() : value;
let hasChildren = grip.ownPropertyLength > 0;
@@ -91,7 +91,7 @@ GripProvider.prototype = {
},
getType: function(object) {
const grip = object && object.getGrip ? object.getGrip() : object;
const grip = object?.getGrip ? object.getGrip() : object;
return grip.class ? grip.class : "";
},
};

View File

@@ -46,10 +46,9 @@ function onRequestProperties(state, action) {
function onReceiveProperties(cache, action) {
const response = action.response;
const from = response.from;
const className =
action.grip && action.grip.getGrip
? action.grip.getGrip().class
: action.grip.class;
const className = action.grip?.getGrip
? action.grip.getGrip().class
: action.grip.class;
// Properly deal with getters.
mergeProperties(response);

View File

@@ -156,7 +156,7 @@ function insertToolMenuElements(doc, toolDefinition, prevDef) {
let ref;
if (prevDef) {
const menuitem = doc.getElementById("menuitem_" + prevDef.id);
ref = menuitem && menuitem.nextSibling ? menuitem.nextSibling : null;
ref = menuitem?.nextSibling ? menuitem.nextSibling : null;
} else {
ref = doc.getElementById("menu_devtools_separator");
}

View File

@@ -814,7 +814,7 @@ Services.obs.addObserver(gDevToolsBrowser, "devtools:loader:destroy");
// Fake end of browser window load event for all already opened windows
// that is already fully loaded.
for (const win of Services.wm.getEnumerator(gDevTools.chromeWindowType)) {
if (win.gBrowserInit && win.gBrowserInit.delayedStartupFinished) {
if (win.gBrowserInit?.delayedStartupFinished) {
gDevToolsBrowser._registerBrowserWindow(win);
}
}

View File

@@ -2119,7 +2119,7 @@ Toolbox.prototype = {
const button = this.pickerButton;
const currentPanel = this.getCurrentPanel();
if (currentPanel && currentPanel.updatePickerButton) {
if (currentPanel?.updatePickerButton) {
currentPanel.updatePickerButton();
} else {
// If the current panel doesn't define a custom updatePickerButton,
@@ -2523,8 +2523,7 @@ Toolbox.prototype = {
* @param {IFrameElement} iframe
*/
setIframeDocumentDir: function(iframe) {
const docEl =
iframe.contentWindow && iframe.contentWindow.document.documentElement;
const docEl = iframe.contentWindow?.document.documentElement;
if (!docEl || docEl.namespaceURI !== HTML_NS) {
// Bail out if the content window or document is not ready or if the document is not
// HTML.
@@ -3514,8 +3513,9 @@ Toolbox.prototype = {
},
inspectObjectActor: async function(objectActor, inspectFromAnnotation) {
const objectGrip =
objectActor && objectActor.getGrip ? objectActor.getGrip() : objectActor;
const objectGrip = objectActor?.getGrip
? objectActor.getGrip()
: objectActor;
if (
objectGrip.preview &&

View File

@@ -23,8 +23,8 @@ class AnimatedPropertyName extends PureComponent {
{
className:
"animated-property-name" +
(state && state.runningOnCompositor ? " compositor" : "") +
(state && state.warning ? " warning" : ""),
(state?.runningOnCompositor ? " compositor" : "") +
(state?.warning ? " warning" : ""),
title: state ? state.warning : "",
},
dom.span({}, name)

View File

@@ -340,7 +340,7 @@ class BoxModelMain extends PureComponent {
this.setAriaActive(nextLayout);
if (target && target._editable) {
if (target?._editable) {
target.blur();
}
@@ -393,7 +393,7 @@ class BoxModelMain extends PureComponent {
);
this.setAriaActive(nextLayout);
if (target && target._editable) {
if (target?._editable) {
target.blur();
}
}

View File

@@ -249,7 +249,7 @@ const reducers = {
rule.selectors.push(selector);
}
if (change.remove && change.remove.length) {
if (change.remove?.length) {
for (const decl of change.remove) {
// Find the position of any added declaration which matches the incoming
// declaration to be removed.
@@ -307,7 +307,7 @@ const reducers = {
}
}
if (change.add && change.add.length) {
if (change.add?.length) {
for (const decl of change.add) {
// Find the position of any removed declaration which matches the incoming
// declaration to be added.

View File

@@ -1537,7 +1537,7 @@ SelectorView.prototype = {
*/
destroy: function() {
const rule = this.selectorInfo.rule;
if (rule && rule.parentStyleSheet && rule.type != ELEMENT_STYLE) {
if (rule?.parentStyleSheet && rule.type != ELEMENT_STYLE) {
const url = rule.parentStyleSheet.href || rule.parentStyleSheet.nodeHref;
this.sourceMapURLService.unsubscribe(
url,

View File

@@ -68,16 +68,14 @@ class ObjectValueGripView extends PureComponent {
disabledFocus: true,
roots: [
{
path:
(expressionResult && expressionResult.actorID) ||
JSON.stringify(expressionResult),
path: expressionResult?.actorID || JSON.stringify(expressionResult),
contents: { value: grip, front: isFront ? expressionResult : null },
},
],
// TODO: evaluate if there should also be a serviceContainer.openLink.
};
if (expressionResult && expressionResult.actorID) {
if (expressionResult?.actorID) {
Object.assign(objectInspectorProps, {
onDOMNodeMouseOver: serviceContainer.highlightDomElement,
onDOMNodeMouseOut: serviceContainer.unHighlightDomElement,

View File

@@ -313,19 +313,14 @@ class FontEditor extends PureComponent {
const { fonts, axes, instance, properties, warning } = fontEditor;
// Pick the first font to show editor controls regardless of how many fonts are used.
const font = fonts[0];
const hasFontAxes = font && font.variationAxes;
const hasFontInstances =
font && font.variationInstances && font.variationInstances.length > 0;
const hasSlantOrItalicAxis =
hasFontAxes &&
font.variationAxes.find(axis => {
return axis.tag === "slnt" || axis.tag === "ital";
});
const hasWeightAxis =
hasFontAxes &&
font.variationAxes.find(axis => {
return axis.tag === "wght";
});
const hasFontAxes = font?.variationAxes;
const hasFontInstances = font?.variationInstances?.length > 0;
const hasSlantOrItalicAxis = font?.variationAxes?.find(axis => {
return axis.tag === "slnt" || axis.tag === "ital";
});
const hasWeightAxis = font?.variationAxes?.find(axis => {
return axis.tag === "wght";
});
// Show the empty state with a warning message when a used font was not found.
if (!font) {

View File

@@ -48,7 +48,7 @@ module.exports = {
}
const match = value.match(/\D+?$/);
return match && match.length ? match[0] : null;
return match?.length ? match[0] : null;
},
/**

View File

@@ -52,13 +52,12 @@ class GridOutline extends PureComponent {
// Store the height of the grid container in the component state to prevent overflow
// issues. We want to store the width of the grid container as well so that the
// viewbox is only the calculated width of the grid outline.
const { width, height } =
selectedGrid && selectedGrid.gridFragments.length
? getTotalWidthAndHeight(selectedGrid)
: { width: 0, height: 0 };
const { width, height } = selectedGrid?.gridFragments.length
? getTotalWidthAndHeight(selectedGrid)
: { width: 0, height: 0 };
let showOutline;
if (selectedGrid && selectedGrid.gridFragments.length) {
if (selectedGrid?.gridFragments.length) {
const { cols, rows } = selectedGrid.gridFragments[0];
// Show the grid outline if both the rows/columns are less than or equal
@@ -371,7 +370,7 @@ class GridOutline extends PureComponent {
render() {
const { selectedGrid } = this.state;
return selectedGrid && selectedGrid.gridFragments.length
return selectedGrid?.gridFragments.length
? dom.div(
{
id: "grid-outline-container",

View File

@@ -182,7 +182,7 @@ class LayoutApp extends PureComponent {
// The reason is that if the user selects an item-container in the markup view, it
// is assumed that they want to primarily see that element as a container, so the
// container info should be at the top.
if (flexItemContainer && flexItemContainer.actorID) {
if (flexItemContainer?.actorID) {
items.splice(
this.props.flexbox.initiatedByMarkupViewSelection ? 1 : 0,
0,

View File

@@ -1753,7 +1753,7 @@ MarkupView.prototype = {
(this.inspector.selection.nodeFront === removedNode && isHTMLTag)
) {
const childContainers = parentContainer.getChildContainers();
if (childContainers && childContainers[childIndex]) {
if (childContainers?.[childIndex]) {
const childContainer = childContainers[childIndex];
this._markContainerAsSelected(childContainer, reason);
if (childContainer.hasChildren) {
@@ -2073,8 +2073,8 @@ MarkupView.prototype = {
return promise.resolve(container);
}
const expand = options && options.expand;
const flash = options && options.flash;
const expand = options?.expand;
const flash = options?.flash;
container.hasChildren = container.node.hasChildren;
// Accessibility should either ignore empty children or semantically

View File

@@ -188,7 +188,7 @@ class ElementStyle {
// We're done with the previous list of rules.
for (const r of existingRules) {
if (r && r.editor) {
if (r?.editor) {
r.editor.destroy();
}

View File

@@ -495,7 +495,7 @@ CssRuleView.prototype = {
try {
let text = "";
const nodeName = target && target.nodeName;
const nodeName = target?.nodeName;
if (nodeName === "input" || nodeName == "textarea") {
const start = Math.min(target.selectionStart, target.selectionEnd);
const end = Math.max(target.selectionStart, target.selectionEnd);

View File

@@ -189,7 +189,7 @@ function getNodeInfo(node, elementStyle) {
classList.contains("ruleview-rule-source-label")
) {
type = VIEW_NODE_LOCATION_TYPE;
value = rule.sheet && rule.sheet.href ? rule.sheet.href : rule.title;
value = rule.sheet?.href ? rule.sheet.href : rule.title;
} else {
return null;
}
@@ -213,7 +213,7 @@ function getNodeInfo(node, elementStyle) {
* @return {Object} {name, value}
*/
function getPropertyNameAndValue(node) {
while (node && node.classList) {
while (node?.classList) {
// Check first for ruleview-computed since it's the deepest
if (
node.classList.contains("ruleview-computed") ||
@@ -240,7 +240,7 @@ function getPropertyNameAndValue(node) {
* @returns {DOMNode} The active shape toggle node, if one exists.
*/
function getShapeToggleActive(node) {
while (node && node.classList) {
while (node?.classList) {
// Check first for ruleview-computed since it's the deepest
if (
node.classList.contains("ruleview-computed") ||

View File

@@ -63,7 +63,7 @@ JsonViewSniffer.prototype = {
isTopLevelLoad: function(request) {
const loadInfo = request.loadInfo;
if (loadInfo && loadInfo.isTopLevelLoad) {
if (loadInfo?.isTopLevelLoad) {
return request.loadFlags & Ci.nsIChannel.LOAD_DOCUMENT_URI;
}
return false;

View File

@@ -381,7 +381,7 @@ const fetchIndividuals = (exports.fetchIndividuals = function(
const snapshot_ = getSnapshot(getState(), id);
assert(
snapshot_.dominatorTree && snapshot_.dominatorTree.root,
snapshot_.dominatorTree?.root,
"Should have a dominator tree with a root."
);
@@ -396,7 +396,7 @@ const fetchIndividuals = (exports.fetchIndividuals = function(
do {
labelDisplay = getState().labelDisplay;
assert(
labelDisplay && labelDisplay.breakdown && labelDisplay.breakdown.by,
labelDisplay?.breakdown?.by,
`Should have a breakdown to label nodes with, got: ${JSON.stringify(
labelDisplay
)}`
@@ -560,7 +560,7 @@ const computeDominatorTree = (exports.computeDominatorTree = TaskCache.declareCa
task: async function(heapWorker, id, removeFromCache, dispatch, getState) {
const snapshot = getSnapshot(getState(), id);
assert(
!(snapshot.dominatorTree && snapshot.dominatorTree.dominatorTreeId),
!snapshot.dominatorTree?.dominatorTreeId,
"Should not re-compute dominator trees"
);
@@ -614,7 +614,7 @@ const fetchDominatorTree = (exports.fetchDominatorTree = TaskCache.declareCachea
do {
display = getState().labelDisplay;
assert(
display && display.breakdown,
display?.breakdown,
`Should have a breakdown to describe nodes with, got: ${JSON.stringify(
display
)}`

View File

@@ -111,7 +111,7 @@ class CensusTreeItem extends Component {
let pointer;
if (inverted && depth > 0) {
pointer = dom.span({ className: "children-pointer" }, "↖");
} else if (!inverted && item.children && item.children.length) {
} else if (!inverted && item.children?.length) {
pointer = dom.span({ className: "children-pointer" }, "↘");
}

View File

@@ -369,10 +369,7 @@ class Heap extends Component {
individuals.state === individualsState.FETCHED,
"Should have fetched individuals"
);
assert(
dominatorTree && dominatorTree.root,
"Should have a dominator tree and its root"
);
assert(dominatorTree?.root, "Should have a dominator tree and its root");
const tree = dom.div(
{

View File

@@ -25,7 +25,7 @@ class TreeMap extends Component {
componentDidMount() {
const { treeMap } = this.props;
if (treeMap && treeMap.report) {
if (treeMap?.report) {
this._startVisualization();
}
}

View File

@@ -199,10 +199,9 @@ class CustomRequestPanel extends Component {
? queryArray.map(({ name, value }) => name + "=" + value).join("\n")
: "";
}
const postData =
requestPostData && requestPostData.postData.text
? requestPostData.postData.text
: "";
const postData = requestPostData?.postData.text
? requestPostData.postData.text
: "";
return div(
{ className: "custom-request-panel" },

View File

@@ -137,7 +137,7 @@ class HeadersPanel extends Component {
getHeadersTitle(headers, title) {
let result;
if (headers && headers.headers.length) {
if (headers?.headers.length) {
result = `${title} (${getFormattedSize(headers.headersSize, 3)})`;
}
@@ -147,7 +147,7 @@ class HeadersPanel extends Component {
getProperties(headers, title) {
let propertiesResult;
if (headers && headers.headers.length) {
if (headers?.headers.length) {
const headerKey = this.getHeadersTitle(headers, title);
propertiesResult = {

View File

@@ -50,7 +50,7 @@ class JSONPreview extends Component {
// Put 2 here to not dup this method
if (
(member.level === 0 && member.type === "object") ||
(typeof member.value === "object" && member.value && member.value.value)
(typeof member.value === "object" && member.value?.value)
) {
return null;
}

View File

@@ -209,7 +209,7 @@ class PropertiesView extends Component {
}
};
if (value && value.text && value.text.length > limit) {
if (value?.text && value.text.length > limit) {
responseTextComponent = div(
{ className: "responseTextContainer" },
pre(

View File

@@ -106,8 +106,7 @@ class StatisticsPanel extends Component {
const { requests } = this.props;
const ready =
requests &&
requests.length &&
requests?.length &&
requests.every(
req =>
req.contentSize !== undefined &&

View File

@@ -221,8 +221,7 @@ class TabboxPanel extends Component {
request,
})
),
request.cause &&
request.cause.stacktraceAvailable &&
request.cause?.stacktraceAvailable &&
TabPanel(
{
id: PANELS.STACK_TRACE,

View File

@@ -134,7 +134,7 @@ class SourcePreview extends Component {
findSearchResult() {
const { targetSearchResult, resetTargetSearchResult } = this.props;
if (targetSearchResult && targetSearchResult.line) {
if (targetSearchResult?.line) {
const { line } = targetSearchResult;
// scroll the editor to center the line
// with the target search result

View File

@@ -157,11 +157,7 @@ class PropertiesView extends Component {
/* Hide strings with following conditions
* - the `value` object has a `value` property (only happens in Cookies panel)
*/
if (
typeof member.value === "object" &&
member.value &&
member.value.value
) {
if (typeof member.value === "object" && member.value?.value) {
return null;
}

View File

@@ -31,7 +31,7 @@ class RequestListColumnInitiator extends Component {
let initiator = "";
let lineNumber = "";
if (cause && cause.lastFrame) {
if (cause?.lastFrame) {
const { filename, lineNumber: _lineNumber } = cause.lastFrame;
initiator = getUrlBaseName(filename);
lineNumber = ":" + _lineNumber;

View File

@@ -400,7 +400,7 @@ class RequestListContent extends Component {
columns,
item,
index,
isSelected: item.id === (selectedRequest && selectedRequest.id),
isSelected: item.id === selectedRequest?.id,
isVisible: this.state.onscreenItems.has(item.id),
key: item.id,
intersectionObserver: this.intersectionObserver,

View File

@@ -71,7 +71,7 @@ const SearchProvider = {
getResourceTooltipLabel(object) {
const { resource } = object;
if (resource.urlDetails && resource.urlDetails.url) {
if (resource.urlDetails?.url) {
return resource.urlDetails.url;
}

View File

@@ -239,7 +239,7 @@ class FramePayload extends Component {
try {
decoder = new JsonHubProtocol();
const msgs = decoder.parseMessages(payload, null);
if (msgs && msgs.length) {
if (msgs?.length) {
return msgs;
}
} catch (err) {

View File

@@ -180,7 +180,7 @@ class FirefoxDataProvider {
async fetchResponseContent(responseContent) {
const payload = {};
if (responseContent && responseContent.content) {
if (responseContent?.content) {
const { text } = responseContent.content;
const response = await this.getLongString(text);
responseContent.content.text = response;
@@ -191,11 +191,7 @@ class FirefoxDataProvider {
async fetchRequestHeaders(requestHeaders) {
const payload = {};
if (
requestHeaders &&
requestHeaders.headers &&
requestHeaders.headers.length
) {
if (requestHeaders?.headers?.length) {
const headers = await fetchHeaders(requestHeaders, this.getLongString);
if (headers) {
payload.requestHeaders = headers;
@@ -206,11 +202,7 @@ class FirefoxDataProvider {
async fetchResponseHeaders(responseHeaders) {
const payload = {};
if (
responseHeaders &&
responseHeaders.headers &&
responseHeaders.headers.length
) {
if (responseHeaders?.headers?.length) {
const headers = await fetchHeaders(responseHeaders, this.getLongString);
if (headers) {
payload.responseHeaders = headers;
@@ -221,7 +213,7 @@ class FirefoxDataProvider {
async fetchPostData(requestPostData) {
const payload = {};
if (requestPostData && requestPostData.postData) {
if (requestPostData?.postData) {
const { text } = requestPostData.postData;
const postData = await this.getLongString(text);
const headers = CurlUtils.getHeadersFromMultipartText(postData);

View File

@@ -201,7 +201,7 @@ HarBuilder.prototype = {
request.headersSize = requestHeaders.headersSize;
request.postData = await this.buildPostData(file);
if (request.postData && request.postData.text) {
if (request.postData?.text) {
request.bodySize = request.postData.text.length;
}
@@ -402,7 +402,7 @@ HarBuilder.prototype = {
"responseContent"
);
}
if (responseContent && responseContent.content) {
if (responseContent?.content) {
content.size = responseContent.content.size;
content.encoding = responseContent.content.encoding;
}
@@ -445,7 +445,7 @@ HarBuilder.prototype = {
if (responseCache.cache) {
cache.afterRequest = this.buildCacheEntry(responseCache.cache);
}
} else if (file.responseCache && file.responseCache.cache) {
} else if (file.responseCache?.cache) {
cache.afterRequest = this.buildCacheEntry(file.responseCache.cache);
} else {
cache.afterRequest = null;

View File

@@ -39,7 +39,7 @@ function batchingMiddleware(store) {
return flushQueue();
}
if (action.meta && action.meta.batch) {
if (action.meta?.batch) {
if (!enabled) {
next(action);
return Promise.resolve();

View File

@@ -252,7 +252,7 @@ function closeCustomRequest(state) {
return {
...state,
// Only custom requests can be removed
[removedRequest && removedRequest.isCustom && "requests"]: requests.filter(
[removedRequest?.isCustom && "requests"]: requests.filter(
item => item.id !== selectedId
),
preselectedId: hasPreselectedId ? null : preselectedId,

View File

@@ -26,7 +26,7 @@ function openRequestInTab(url, requestHeaders, requestPostData) {
const rawData = requestPostData ? requestPostData.postData : null;
let postData;
if (rawData && rawData.text) {
if (rawData?.text) {
const stringStream = getInputStreamFromString(rawData.text);
postData = Cc["@mozilla.org/network/mime-input-stream;1"].createInstance(
Ci.nsIMIMEInputStream

View File

@@ -197,7 +197,7 @@ function getUrl(url) {
*/
function getUrlProperty(input, property) {
const url = getUrl(input);
return url && url[property] ? url[property] : "";
return url?.[property] ? url[property] : "";
}
/**

View File

@@ -202,7 +202,7 @@ function getType(resource) {
*/
function getValue(path, obj) {
const properties = Array.isArray(path) ? path : path.split(".");
return properties.reduce((prev, curr) => prev && prev[curr], obj);
return properties.reduce((prev, curr) => prev?.[curr], obj);
}
/**

View File

@@ -382,8 +382,7 @@ function isNumeric(c) {
function shouldDemangle(name) {
return (
name &&
name.charCodeAt &&
name?.charCodeAt &&
name.charCodeAt(0) === CHAR_CODE_UNDERSCORE &&
name.charCodeAt(1) === CHAR_CODE_UNDERSCORE &&
name.charCodeAt(2) === CHAR_CODE_CAP_Z
@@ -451,7 +450,7 @@ function getFrameInfo(node, options) {
// if it does not.
const totalSamples = options.root.samples;
const totalDuration = options.root.duration;
if (options && options.root && !data.COSTS_CALCULATED) {
if (options?.root && !data.COSTS_CALCULATED) {
data.selfDuration =
(node.youngestFrameSamples / totalSamples) * totalDuration;
data.selfPercentage = (node.youngestFrameSamples / totalSamples) * 100;
@@ -460,7 +459,7 @@ function getFrameInfo(node, options) {
data.COSTS_CALCULATED = true;
}
if (options && options.allocations && !data.ALLOCATION_DATA_CALCULATED) {
if (options?.allocations && !data.ALLOCATION_DATA_CALCULATED) {
const totalBytes = options.root.byteSize;
data.selfCount = node.youngestFrameSamples;
data.totalCount = node.samples;

View File

@@ -168,10 +168,9 @@ const DetailsView = {
return false;
}
const prefSupported =
prefs && prefs.length
? prefs.every(p => PerformanceController.getPref(p))
: true;
const prefSupported = prefs?.length
? prefs.every(p => PerformanceController.getPref(p))
: true;
return PerformanceController.isFeatureSupported(features) && prefSupported;
},

View File

@@ -91,7 +91,7 @@ function tunnelToInnerBrowser(outer, inner) {
// <iframe mozbrowser>.
const mirroringProgressListener = {
onStateChange: (webProgress, request, stateFlags, status) => {
if (webProgress && webProgress.isTopLevel) {
if (webProgress?.isTopLevel) {
inner._characterSet = outer._characterSet;
inner._documentURI = outer._documentURI;
inner._documentContentType = outer._documentContentType;
@@ -99,7 +99,7 @@ function tunnelToInnerBrowser(outer, inner) {
},
onLocationChange: (webProgress, request, location, flags) => {
if (webProgress && webProgress.isTopLevel) {
if (webProgress?.isTopLevel) {
inner._documentURI = outer._documentURI;
inner._documentContentType = outer._documentContentType;
inner._contentTitle = outer._contentTitle;

View File

@@ -276,7 +276,7 @@ class ResponsiveUIManager {
}
removeMenuCheckListenerFor(window) {
if (window && window.gBrowser && window.gBrowser.tabContainer) {
if (window?.gBrowser?.tabContainer) {
const { tabContainer } = window.gBrowser;
tabContainer.removeEventListener("TabSelect", this.handleMenuCheck);
}

View File

@@ -23,8 +23,7 @@ exports.getDOMWindowUtils = getDOMWindowUtils;
* Check if the given browser window has finished the startup.
* @params {nsIDOMWindow} window
*/
const isStartupFinished = window =>
window.gBrowserInit && window.gBrowserInit.delayedStartupFinished;
const isStartupFinished = window => window.gBrowserInit?.delayedStartupFinished;
function startup(window) {
return new Promise(resolve => {

View File

@@ -178,7 +178,7 @@ class SmartTrace extends Component {
}
this.setState(state => {
const stacktrace = (state && state.stacktrace) || this.props.stacktrace;
const stacktrace = state?.stacktrace || this.props.stacktrace;
const frame = { ...stacktrace[index] };
// Remove any sourceId that might confuse the viewSource util.
delete frame.sourceId;

View File

@@ -96,7 +96,7 @@ define(function(require, exports, module) {
// Render value using a default render function or custom
// provided function from props or a decorator.
renderValue = renderValue || defaultRenderValue;
if (decorator && decorator.renderValue) {
if (decorator?.renderValue) {
renderValue = decorator.renderValue(member.object, id) || renderValue;
}

View File

@@ -250,7 +250,7 @@ define(function(require, exports, module) {
// Get components for rendering cells.
let renderCell = this.props.renderCell || RenderCell;
let renderLabelCell = this.props.renderLabelCell || RenderLabelCell;
if (decorator && decorator.renderLabelCell) {
if (decorator?.renderLabelCell) {
renderLabelCell =
decorator.renderLabelCell(member.object) || renderLabelCell;
}
@@ -263,7 +263,7 @@ define(function(require, exports, module) {
value: this.props.provider.getValue(member.object, col.id),
});
if (decorator && decorator.renderCell) {
if (decorator?.renderCell) {
renderCell = decorator.renderCell(member.object, col.id);
}

View File

@@ -276,7 +276,7 @@ define(function(require, exports, module) {
get visibleRows() {
return this.rows.filter(row => {
const rowEl = findDOMNode(row);
return rowEl && rowEl.offsetParent;
return rowEl?.offsetParent;
});
}
@@ -325,7 +325,7 @@ define(function(require, exports, module) {
}
break;
case "ArrowLeft":
if (row && row.props.member.open) {
if (row?.props.member.open) {
this.toggle(this.state.selected);
} else {
const parentRow = rows
@@ -601,7 +601,7 @@ define(function(require, exports, module) {
}
members.forEach(member => {
if (decorator && decorator.renderRow) {
if (decorator?.renderRow) {
renderRow = decorator.renderRow(member.object) || renderRow;
}

View File

@@ -583,7 +583,7 @@ InplaceEditor.prototype = {
*/
_incrementCSSValue: function(value, increment, selStart, selEnd) {
const range = this._parseCSSValue(value, selStart);
const type = (range && range.type) || "";
const type = range?.type || "";
const rawValue = range ? value.substring(range.start, range.end) : "";
const preRawValue = range ? value.substr(0, range.start) : "";
const postRawValue = range ? value.substr(range.end) : "";

View File

@@ -14,12 +14,12 @@ const { TargetFactory } = require("devtools/client/framework/target");
function _getTopWindow() {
// Try the main application window, such as a browser window.
let win = Services.wm.getMostRecentWindow(gDevTools.chromeWindowType);
if (win && win.openWebLinkIn && win.openTrustedLinkIn) {
if (win?.openWebLinkIn && win?.openTrustedLinkIn) {
return win;
}
// For non-browser cases like Browser Toolbox, try any chrome window.
win = Services.wm.getMostRecentWindow(null);
if (win && win.openWebLinkIn && win.openTrustedLinkIn) {
if (win?.openWebLinkIn && win?.openTrustedLinkIn) {
return win;
}
return null;

View File

@@ -70,7 +70,7 @@ function initializeAutoCompletion(ctx, options = {}) {
});
const cycle = reverse => {
if (popup && popup.isOpen) {
if (popup?.isOpen) {
// eslint-disable-next-line mozilla/no-compare-against-boolean-literals
cycleSuggestions(ed, reverse == true);
return null;
@@ -337,7 +337,7 @@ function getPopup({ ed }) {
function getInfoAt({ ed }, caret) {
if (autocompleteMap.has(ed)) {
const completer = autocompleteMap.get(ed).completer;
if (completer && completer.getInfoAt) {
if (completer?.getInfoAt) {
return completer.getInfoAt(ed.getText(), caret);
}
}

View File

@@ -212,7 +212,7 @@ function Editor(config) {
// indenting with tabs, insert one tab. Otherwise insert N
// whitespaces where N == indentUnit option.
this.config.extraKeys.Tab = cm => {
if (config.extraKeys && config.extraKeys.Tab) {
if (config.extraKeys?.Tab) {
// If a consumer registers its own extraKeys.Tab, we execute it before doing
// anything else. If it returns false, that mean that all the key handling work is
// done, so we can do an early return.
@@ -259,7 +259,7 @@ Editor.prototype = {
*/
get CodeMirror() {
const codeMirror = editors.get(this);
return codeMirror && codeMirror.constructor;
return codeMirror?.constructor;
},
/**
@@ -1436,7 +1436,7 @@ Editor.prototype = {
// Remove the link between the document and code-mirror.
const cm = editors.get(this);
if (cm && cm.doc) {
if (cm?.doc) {
cm.doc.cm = null;
}

View File

@@ -42,9 +42,7 @@ module.exports = (env, argv) => {
],
optimization: {
minimize: !(
argv &&
argv.optimization &&
argv.optimization.minimizer === "false"
argv?.optimization && argv.optimization.minimizer === "false"
),
},
output: {

View File

@@ -193,7 +193,7 @@ TreeWidget.prototype = {
}
node = node.parentNode;
while (node.parentNode && node != this.root.children) {
if (node.parentNode && node.parentNode.nextSibling) {
if (node.parentNode?.nextSibling) {
return JSON.parse(node.parentNode.nextSibling.getAttribute("data-id"));
}
node = node.parentNode;

Some files were not shown because too many files have changed in this diff Show More