react / react-0.13.3 / examples / basic-commonjs / node_modules / reactify / node_modules / react-tools / src / browser / ui / dom / components / ReactDOMForm.js
81165 views/**1* Copyright 2013-2014, Facebook, Inc.2* All rights reserved.3*4* This source code is licensed under the BSD-style license found in the5* LICENSE file in the root directory of this source tree. An additional grant6* of patent rights can be found in the PATENTS file in the same directory.7*8* @providesModule ReactDOMForm9*/1011"use strict";1213var EventConstants = require('EventConstants');14var LocalEventTrapMixin = require('LocalEventTrapMixin');15var ReactBrowserComponentMixin = require('ReactBrowserComponentMixin');16var ReactCompositeComponent = require('ReactCompositeComponent');17var ReactElement = require('ReactElement');18var ReactDOM = require('ReactDOM');1920// Store a reference to the <form> `ReactDOMComponent`. TODO: use string21var form = ReactElement.createFactory(ReactDOM.form.type);2223/**24* Since onSubmit doesn't bubble OR capture on the top level in IE8, we need25* to capture it on the <form> element itself. There are lots of hacks we could26* do to accomplish this, but the most reliable is to make <form> a27* composite component and use `componentDidMount` to attach the event handlers.28*/29var ReactDOMForm = ReactCompositeComponent.createClass({30displayName: 'ReactDOMForm',3132mixins: [ReactBrowserComponentMixin, LocalEventTrapMixin],3334render: 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 open37// source repo, we need to just use `ReactDOM.form`.38return form(this.props);39},4041componentDidMount: function() {42this.trapBubbledEvent(EventConstants.topLevelTypes.topReset, 'reset');43this.trapBubbledEvent(EventConstants.topLevelTypes.topSubmit, 'submit');44}45});4647module.exports = ReactDOMForm;484950