Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
80517 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 ReactDOMForm
10
*/
11
12
'use strict';
13
14
var EventConstants = require("./EventConstants");
15
var LocalEventTrapMixin = require("./LocalEventTrapMixin");
16
var ReactBrowserComponentMixin = require("./ReactBrowserComponentMixin");
17
var ReactClass = require("./ReactClass");
18
var ReactElement = require("./ReactElement");
19
20
var form = ReactElement.createFactory('form');
21
22
/**
23
* Since onSubmit doesn't bubble OR capture on the top level in IE8, we need
24
* to capture it on the <form> element itself. There are lots of hacks we could
25
* do to accomplish this, but the most reliable is to make <form> a
26
* composite component and use `componentDidMount` to attach the event handlers.
27
*/
28
var ReactDOMForm = ReactClass.createClass({
29
displayName: 'ReactDOMForm',
30
tagName: 'FORM',
31
32
mixins: [ReactBrowserComponentMixin, LocalEventTrapMixin],
33
34
render: function() {
35
// TODO: Instead of using `ReactDOM` directly, we should use JSX. However,
36
// `jshint` fails to parse JSX so in order for linting to work in the open
37
// source repo, we need to just use `ReactDOM.form`.
38
return form(this.props);
39
},
40
41
componentDidMount: function() {
42
this.trapBubbledEvent(EventConstants.topLevelTypes.topReset, 'reset');
43
this.trapBubbledEvent(EventConstants.topLevelTypes.topSubmit, 'submit');
44
}
45
});
46
47
module.exports = ReactDOMForm;
48
49