Commit bb7bd2b2 authored by Antoine's avatar Antoine
Browse files

[client] Add checks against null when manipulating DOM nodes.

parent 38b67649
Pipeline #353339 passed with stage
in 4 minutes and 29 seconds
......@@ -39,16 +39,18 @@ export default connect(
}
let selection = window.getSelection();
selection.removeAllRanges();
if (selection !== null) {
selection.removeAllRanges();
let range = document.createRange();
range.selectNodeContents(this.refLogsContent.current);
selection.addRange(range);
let range = document.createRange();
range.selectNodeContents(this.refLogsContent.current);
selection.addRange(range);
document.execCommand('copy');
document.execCommand('copy');
selection.removeAllRanges();
notify.success($t('client.settings.logs.copied'));
selection.removeAllRanges();
notify.success($t('client.settings.logs.copied'));
}
};
componentWillUnmount() {
......
......@@ -34,16 +34,18 @@ class ErrorReporter extends React.Component {
}
let selection = window.getSelection();
selection.removeAllRanges();
if (selection !== null) {
selection.removeAllRanges();
let range = document.createRange();
range.selectNodeContents(this.refErrorContentNode);
selection.addRange(range);
let range = document.createRange();
range.selectNodeContents(this.refErrorContentNode);
selection.addRange(range);
document.execCommand('copy');
document.execCommand('copy');
selection.removeAllRanges();
window.alert($t('client.settings.logs.copied'));
selection.removeAllRanges();
window.alert($t('client.settings.logs.copied'));
}
};
render() {
......
......@@ -74,16 +74,19 @@ export default class InfiniteList extends React.PureComponent {
componentDidMount() {
let container = document.getElementById(this.props.containerId);
container.addEventListener('scroll', this.handleScroll);
if (container !== null) {
container.addEventListener('scroll', this.handleScroll);
// Ensure the top of the list is always visible when remounting the component.
container.scrollTop = 0;
// Ensure the top of the list is always visible when remounting the component.
container.scrollTop = 0;
}
}
componentWillUnmount() {
document
.getElementById(this.props.containerId)
.removeEventListener('scroll', this.handleScroll);
let container = document.getElementById(this.props.containerId);
if (container !== null) {
container.removeEventListener('scroll', this.handleScroll);
}
}
handleScroll = e => {
......
......@@ -44,19 +44,21 @@ function withLongPress(WrappedComponent) {
};
componentDidMount() {
ReactDOM.findDOMNode(this.refComponent.current).addEventListener(
'touchstart',
this.onPressStart
);
let domElement = ReactDOM.findDOMNode(this.refComponent.current);
if (domElement !== null) {
domElement.addEventListener('touchstart', this.onPressStart);
}
}
componentWillUnmount() {
let domElement = ReactDOM.findDOMNode(this.refComponent.current);
domElement.removeEventListener('touchstart', this.onPressStart);
domElement.removeEventListener('touchend', this.onPressEnd);
domElement.removeEventListener('touchmove', this.onPressEnd);
domElement.removeEventListener('touchcancel', this.onPressEnd);
domElement.removeEventListener('contextmenu', this.onContextMenu);
if (domElement !== null) {
domElement.removeEventListener('touchstart', this.onPressStart);
domElement.removeEventListener('touchend', this.onPressEnd);
domElement.removeEventListener('touchmove', this.onPressEnd);
domElement.removeEventListener('touchcancel', this.onPressEnd);
domElement.removeEventListener('contextmenu', this.onContextMenu);
}
}
render() {
......
......@@ -273,7 +273,9 @@ export default function runKresus() {
const appElement = document.getElementById('app');
// Remove the loading class on the app element.
appElement.classList.remove('before-load');
if (appElement !== null) {
appElement.classList.remove('before-load');
}
let urlPrefix = get.instanceProperty(initialState, URL_PREFIX);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment