/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
componentDidMount() { if (this.messageNode) { if (this.props.scrollToMessage) { this.messageNode.scrollIntoView();
}
this.emitNewMessage(this.messageNode);
}
}
componentDidCatch(e) { this.setState({ error: e });
}
// Event used in tests. Some message types don't pass it in because existing tests // did not emit for them.
emitNewMessage(node) { const { serviceContainer, messageId, timeStamp } = this.props;
serviceContainer.emitForTests( "new-messages", new Set([{ node, messageId, timeStamp }])
);
}
toggleMessage(e) { // Don't bubble up to the main App component, which redirects focus to input, // making difficult for screen reader users to review output
e.stopPropagation(); const { open, dispatch, messageId, onToggle, disabled } = this.props;
if (disabled) { return;
}
// Early exit the function to avoid the message to collapse if the user is // selecting a range in the toggle message. const window = e.target.ownerDocument.defaultView; if (window.getSelection && window.getSelection().type === "Range") { return;
}
// If defined on props, we let the onToggle() method handle the toggling, // otherwise we toggle the message open/closed ourselves. if (onToggle) {
onToggle(messageId, e);
} elseif (open) {
dispatch(actions.messageClose(messageId));
} else {
dispatch(actions.messageOpen(messageId));
}
}
// The message can hold one or multiple fronts that we need to serialize if (value?.getGrip) { return value.getGrip();
} return value;
},
2
)
),
},
l10n.getStr( "webconsole.message.componentDidCatch.copyButton.label"
)
)
)
)
),
dom.br()
);
}
// Figure out if there is an expandable part to the message.
let attachment = null; if (this.props.attachment) {
attachment = this.props.attachment;
} elseif (stacktrace && open) { const smartTraceAttributes = {
stacktrace,
onViewSourceInDebugger:
serviceContainer.onViewSourceInDebugger ||
serviceContainer.onViewSource,
onViewSource: serviceContainer.onViewSource,
onReady: this.props.maybeScrollToBottom,
sourceMapURLService: serviceContainer.sourceMapURLService,
};
if (serviceContainer.preventStacktraceInitialRenderDelay) {
smartTraceAttributes.initialRenderDelay = 0;
}
// If there is an expandable part, make it collapsible.
let collapse = null; if (collapsible && !disabled) {
collapse = createElement(CollapseButton, {
open,
title: collapseTitle,
onClick: this.toggleMessage,
});
}
let onFrameClick; if (serviceContainer && frame) { if (source === MESSAGE_SOURCE.CSS) {
onFrameClick =
serviceContainer.onViewSourceInStyleEditor ||
serviceContainer.onViewSource;
} else { // Point everything else to debugger, if source not available, // it will fall back to view-source.
onFrameClick =
serviceContainer.onViewSourceInDebugger ||
serviceContainer.onViewSource;
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.