MCPcopy Index your code
hub / github.com/docker/getting-started / RootCloseWrapper

Function RootCloseWrapper

app/src/static/js/react-bootstrap.js:5765–5814  ·  view source on GitHub ↗
(props, context)

Source from the content-addressed store, hash-verified

5763 _inheritsLoose(RootCloseWrapper, _React$Component);
5764
5765 function RootCloseWrapper(props, context) {
5766 var _this;
5767
5768 _this = _React$Component.call(this, props, context) || this;
5769
5770 _this.addEventListeners = function () {
5771 var event = _this.props.event;
5772 var doc = (0, _ownerDocument.default)(_assertThisInitialized(_assertThisInitialized(_this))); // Use capture for this listener so it fires before React's listener, to
5773 // avoid false positives in the contains() check below if the target DOM
5774 // element is removed in the React mouse callback.
5775
5776 _this.removeMouseCaptureListener = (0, _listen.default)(doc, event, _this.handleMouseCapture, true);
5777 _this.removeMouseListener = (0, _listen.default)(doc, event, _this.handleMouse);
5778 _this.removeKeyupListener = (0, _listen.default)(doc, 'keyup', _this.handleKeyUp);
5779
5780 if ('ontouchstart' in doc.documentElement) {
5781 _this.mobileSafariHackListeners = [].slice.call(document.body.children).map(function (el) {
5782 return (0, _listen.default)(el, 'mousemove', noop);
5783 });
5784 }
5785 };
5786
5787 _this.removeEventListeners = function () {
5788 if (_this.removeMouseCaptureListener) _this.removeMouseCaptureListener();
5789 if (_this.removeMouseListener) _this.removeMouseListener();
5790 if (_this.removeKeyupListener) _this.removeKeyupListener();
5791 if (_this.mobileSafariHackListeners) _this.mobileSafariHackListeners.forEach(function (remove) {
5792 return remove();
5793 });
5794 };
5795
5796 _this.handleMouseCapture = function (e) {
5797 _this.preventMouseRootClose = isModifiedEvent(e) || !isLeftClickEvent(e) || (0, _contains.default)(_reactDom.default.findDOMNode(_assertThisInitialized(_assertThisInitialized(_this))), e.target);
5798 };
5799
5800 _this.handleMouse = function (e) {
5801 if (!_this.preventMouseRootClose && _this.props.onRootClose) {
5802 _this.props.onRootClose(e);
5803 }
5804 };
5805
5806 _this.handleKeyUp = function (e) {
5807 if (e.keyCode === escapeKeyCode && _this.props.onRootClose) {
5808 _this.props.onRootClose(e);
5809 }
5810 };
5811
5812 _this.preventMouseRootClose = false;
5813 return _this;
5814 }
5815
5816 var _proto = RootCloseWrapper.prototype;
5817

Callers

nothing calls this directly

Calls 3

_assertThisInitializedFunction · 0.85
isModifiedEventFunction · 0.85
isLeftClickEventFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…