react / react-0.13.3 / examples / basic-commonjs / node_modules / reactify / node_modules / react-tools / src / browser / ui / dom / components / ReactDOMImg.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 ReactDOMImg9*/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 <img> `ReactDOMComponent`. TODO: use string21var img = ReactElement.createFactory(ReactDOM.img.type);2223/**24* Since onLoad doesn't bubble OR capture on the top level in IE8, we need to25* capture it on the <img> element itself. There are lots of hacks we could do26* to accomplish this, but the most reliable is to make <img> a composite27* component and use `componentDidMount` to attach the event handlers.28*/29var ReactDOMImg = ReactCompositeComponent.createClass({30displayName: 'ReactDOMImg',31tagName: 'IMG',3233mixins: [ReactBrowserComponentMixin, LocalEventTrapMixin],3435render: function() {36return img(this.props);37},3839componentDidMount: function() {40this.trapBubbledEvent(EventConstants.topLevelTypes.topLoad, 'load');41this.trapBubbledEvent(EventConstants.topLevelTypes.topError, 'error');42}43});4445module.exports = ReactDOMImg;464748