Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
80529 views
1
/**
2
* Copyright 2013-2015, Facebook, Inc.
3
* All rights reserved.
4
*
5
* This source code is licensed under the BSD-style license found in the
6
* LICENSE file in the root directory of this source tree. An additional grant
7
* of patent rights can be found in the PATENTS file in the same directory.
8
*
9
* @providesModule ReactDOMButton
10
*/
11
12
'use strict';
13
14
var AutoFocusMixin = require("./AutoFocusMixin");
15
var ReactBrowserComponentMixin = require("./ReactBrowserComponentMixin");
16
var ReactClass = require("./ReactClass");
17
var ReactElement = require("./ReactElement");
18
19
var keyMirror = require("./keyMirror");
20
21
var button = ReactElement.createFactory('button');
22
23
var mouseListenerNames = keyMirror({
24
onClick: true,
25
onDoubleClick: true,
26
onMouseDown: true,
27
onMouseMove: true,
28
onMouseUp: true,
29
onClickCapture: true,
30
onDoubleClickCapture: true,
31
onMouseDownCapture: true,
32
onMouseMoveCapture: true,
33
onMouseUpCapture: true
34
});
35
36
/**
37
* Implements a <button> native component that does not receive mouse events
38
* when `disabled` is set.
39
*/
40
var ReactDOMButton = ReactClass.createClass({
41
displayName: 'ReactDOMButton',
42
tagName: 'BUTTON',
43
44
mixins: [AutoFocusMixin, ReactBrowserComponentMixin],
45
46
render: function() {
47
var props = {};
48
49
// Copy the props; except the mouse listeners if we're disabled
50
for (var key in this.props) {
51
if (this.props.hasOwnProperty(key) &&
52
(!this.props.disabled || !mouseListenerNames[key])) {
53
props[key] = this.props[key];
54
}
55
}
56
57
return button(props, this.props.children);
58
}
59
60
});
61
62
module.exports = ReactDOMButton;
63
64