react-winjs.js
function PropHandlers_mountTo(getMountPoint) {
        return {
            propType: React.PropTypes.element,
            // Can't use preCtorInit because the mount point may not exist until the
            // constructor has run.
            update: function mountTo_update(winjsComponent, propName, oldValue, newValue) {
                var data = winjsComponent.data[propName] || {};
                var version = (data.version || 0) + 1;
                winjsComponent.data[propName] = {
                    // *mountComponent* may run asynchronously and we may queue it multiple
                    // times before it runs. *version* allows us to ensure only the latest
                    // version runs and the others are no ops.
                    version: version,
                    // *element* is the element to which we last mounted the component.
                    element: data.element
                };

                var mountComponent = function () {
                    if (version === winjsComponent.data[propName].version) {
                        var oldElement = winjsComponent.data[propName].element;

                        if (newValue) {
                            var newElement = getMountPoint(winjsComponent);
                            if (oldElement && oldElement !== newElement) {
                                ReactDOM.unmountComponentAtNode(oldElement);
                            }

                            ReactDOM.render(newValue, newElement);
                            winjsComponent.data[propName].element = newElement;
                        } else if (oldValue) {
                            oldElement && ReactDOM.unmountComponentAtNode(oldElement);
                            winjsComponent.data[propName].element = null;
                        }
                    }
                };

                // *isDeclarativeControlContainer* is a hook some WinJS controls provide
                // (e.g. HubSection, PivotItem) to ensure that processing runs on the
                // control only when the control is ready for it. This enables lazy loading
                // of HubSections/PivotItems (e.g. load off screen items asynchronously in
                // batches). Additionally, doing processing thru this hook guarantees that
                // the processing won't run until the control is in the DOM.
                var winControl = winjsComponent.winControl;
                var queueProcessing = winControl.constructor.isDeclarativeControlContainer;
                if (queueProcessing && typeof queueProcessing === "function") {
                    queueProcessing(winControl, mountComponent);
                } else {
                    mountComponent();
                }
            },
            dispose: function mountTo_dispose(winjsComponent, propName) {
                var data = winjsComponent.data[propName] || {};
                var element = data.element;
                element && ReactDOM.unmountComponentAtNode(element);
            }
        };
    }
function PropHandlers_mountTo(getMountPoint) {
        return {
            propType: React.PropTypes.element,
            // Can't use preCtorInit because the mount point may not exist until the
            // constructor has run.
            update: function mountTo_update(winjsComponent, propName, oldValue, newValue) {
                var data = winjsComponent.data[propName] || {};
                var version = (data.version || 0) + 1;
                winjsComponent.data[propName] = {
                    // *mountComponent* may run asynchronously and we may queue it multiple
                    // times before it runs. *version* allows us to ensure only the latest
                    // version runs and the others are no ops.
                    version: version,
                    // *element* is the element to which we last mounted the component.
                    element: data.element
                };

                var mountComponent = function () {
                    if (version === winjsComponent.data[propName].version) {
                        var oldElement = winjsComponent.data[propName].element;

                        if (newValue) {
                            var newElement = getMountPoint(winjsComponent);
                            if (oldElement && oldElement !== newElement) {
                                ReactDOM.unmountComponentAtNode(oldElement);
                            }

                            ReactDOM.render(newValue, newElement);
                            winjsComponent.data[propName].element = newElement;
                        } else if (oldValue) {
                            oldElement && ReactDOM.unmountComponentAtNode(oldElement);
                            winjsComponent.data[propName].element = null;
                        }
                    }
                };

                // *isDeclarativeControlContainer* is a hook some WinJS controls provide
                // (e.g. HubSection, PivotItem) to ensure that processing runs on the
                // control only when the control is ready for it. This enables lazy loading
                // of HubSections/PivotItems (e.g. load off screen items asynchronously in
                // batches). Additionally, doing processing thru this hook guarantees that
                // the processing won't run until the control is in the DOM.
                var winControl = winjsComponent.winControl;
                var queueProcessing = winControl.constructor.isDeclarativeControlContainer;
                if (queueProcessing && typeof queueProcessing === "function") {
                    queueProcessing(winControl, mountComponent);
                } else {
                    mountComponent();
                }
            },
            dispose: function mountTo_dispose(winjsComponent, propName) {
                var data = winjsComponent.data[propName] || {};
                var element = data.element;
                element && ReactDOM.unmountComponentAtNode(element);
            }
        };
    }
function PropHandlers_mountTo ( getMountPoint ) { return { propType : React . PropTypes . element , // Can't use preCtorInit because the mount point may not exist until the // constructor has run. update : function mountTo_update ( winjsComponent , propName , oldValue , newValue ) { var data = winjsComponent . data [ propName ] || { } ; var version = ( data . version || 0 ) + 1 ; winjsComponent . data [ propName ] = { // *mountComponent* may run asynchronously and we may queue it multiple // times before it runs. *version* allows us to ensure only the latest // version runs and the others are no ops. version : version , // *element* is the element to which we last mounted the component. element : data . element } ; var mountComponent = function ( ) { if ( version === winjsComponent . data [ propName ] . version ) { var oldElement = winjsComponent . data [ propName ] . element ; if ( newValue ) { var newElement = getMountPoint ( winjsComponent ) ; if ( oldElement && oldElement !== newElement ) { ReactDOM . unmountComponentAtNode ( oldElement ) ; } ReactDOM . render ( newValue , newElement ) ; winjsComponent . data [ propName ] . element = newElement ; } else if ( oldValue ) { oldElement && ReactDOM . unmountComponentAtNode ( oldElement ) ; winjsComponent . data [ propName ] . element = null ; } } } ; // *isDeclarativeControlContainer* is a hook some WinJS controls provide // (e.g. HubSection, PivotItem) to ensure that processing runs on the // control only when the control is ready for it. This enables lazy loading // of HubSections/PivotItems (e.g. load off screen items asynchronously in // batches). Additionally, doing processing thru this hook guarantees that // the processing won't run until the control is in the DOM. var winControl = winjsComponent . winControl ; var queueProcessing = winControl . constructor . isDeclarativeControlContainer ; if ( queueProcessing && typeof queueProcessing === "function" ) { queueProcessing ( winControl , mountComponent ) ; } else { mountComponent ( ) ; } } , dispose : function mountTo_dispose ( winjsComponent , propName ) { var data = winjsComponent . data [ propName ] || { } ; var element = data . element ; element && ReactDOM . unmountComponentAtNode ( element ) ; } } ; }
Mounts a React component on whatever element gets returned by getMountPoint.
Mounts a React component on whatever element gets returned by getMountPoint .