mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-31 17:38:48 +00:00
react app
This commit is contained in:
53
react-app/node_modules/react/lib/LocalEventTrapMixin.js
generated
vendored
Normal file
53
react-app/node_modules/react/lib/LocalEventTrapMixin.js
generated
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
/**
|
||||
* Copyright 2014-2015, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*
|
||||
* @providesModule LocalEventTrapMixin
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
var ReactBrowserEventEmitter = require("./ReactBrowserEventEmitter");
|
||||
|
||||
var accumulateInto = require("./accumulateInto");
|
||||
var forEachAccumulated = require("./forEachAccumulated");
|
||||
var invariant = require("./invariant");
|
||||
|
||||
function remove(event) {
|
||||
event.remove();
|
||||
}
|
||||
|
||||
var LocalEventTrapMixin = {
|
||||
trapBubbledEvent:function(topLevelType, handlerBaseName) {
|
||||
("production" !== process.env.NODE_ENV ? invariant(this.isMounted(), 'Must be mounted to trap events') : invariant(this.isMounted()));
|
||||
// If a component renders to null or if another component fatals and causes
|
||||
// the state of the tree to be corrupted, `node` here can be null.
|
||||
var node = this.getDOMNode();
|
||||
("production" !== process.env.NODE_ENV ? invariant(
|
||||
node,
|
||||
'LocalEventTrapMixin.trapBubbledEvent(...): Requires node to be rendered.'
|
||||
) : invariant(node));
|
||||
var listener = ReactBrowserEventEmitter.trapBubbledEvent(
|
||||
topLevelType,
|
||||
handlerBaseName,
|
||||
node
|
||||
);
|
||||
this._localEventListeners =
|
||||
accumulateInto(this._localEventListeners, listener);
|
||||
},
|
||||
|
||||
// trapCapturedEvent would look nearly identical. We don't implement that
|
||||
// method because it isn't currently needed.
|
||||
|
||||
componentWillUnmount:function() {
|
||||
if (this._localEventListeners) {
|
||||
forEachAccumulated(this._localEventListeners, remove);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = LocalEventTrapMixin;
|
Reference in New Issue
Block a user