Bug 1874684 - Part 4: Prefer const references instead of copying Instant values....
[gecko.git] / devtools / client / shared / events.js
blobfcfd32d3bf0894ea39318b44069b3e6b79106a55
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2  * License, v. 2.0. If a copy of the MPL was not distributed with this
3  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4 "use strict";
6 /**
7  * Prevent event default behaviour and stop its propagation.
8  * @param  {Object} event
9  *         Event or react synthetic event.
10  */
11 exports.preventDefaultAndStopPropagation = function (event) {
12   event.preventDefault();
13   event.stopPropagation();
14   if (event.nativeEvent) {
15     if (event.nativeEvent.preventDefault) {
16       event.nativeEvent.preventDefault();
17     }
18     if (event.nativeEvent.stopPropagation) {
19       event.nativeEvent.stopPropagation();
20     }
21   }