1
0
mirror of https://github.com/ascribe/onion.git synced 2024-12-22 09:23:13 +01:00

Replace getDOMNode with findDOMNode

This commit is contained in:
tim 2016-05-09 11:12:46 +02:00
parent 8c111a2977
commit 7a0255acd5
12 changed files with 34 additions and 21 deletions

View File

@ -1,6 +1,7 @@
'use strict';
import React from 'react';
import ReactDOM from 'react-dom';
import UserActions from '../../actions/user_actions';
import UserStore from '../../stores/user_store';
@ -61,7 +62,7 @@ let AclButtonList = React.createClass({
handleResize() {
this.setState({
buttonListSize: this.refs.buttonList.getDOMNode().offsetWidth
buttonListSize: ReactDOM.findDOMNode(this.refs.buttonList).offsetWidth
});
},

View File

@ -1,6 +1,7 @@
'use strict';
import React from 'react';
import ReactDOM from 'react-dom';
import Button from 'react-bootstrap/lib/Button';
import AlertDismissable from './alert';
@ -343,7 +344,7 @@ let Form = React.createClass({
let refToValidate = {};
const property = this.refs[refName];
const input = property.refs.input;
const value = input.getDOMNode().value || input.state.value;
const value = ReactDOM.findDOMNode(input).value || input.state.value;
const { max,
min,
pattern,

View File

@ -1,6 +1,7 @@
'use strict';
import React from 'react';
import ReactDOM from 'react-dom';
/**
* This component can be used as a custom input element for form properties.
@ -71,7 +72,7 @@ let InputCheckbox = React.createClass({
}
// On every change, we're inversing the input's value
let inverseValue = !this.refs.checkbox.getDOMNode().checked;
let inverseValue = !ReactDOM.findDOMNode(this.refs.checkbox).checked;
// pass it to the state
this.setState({value: inverseValue});

View File

@ -1,6 +1,7 @@
'use strict';
import React from 'react';
import ReactDOM from 'react-dom';
import Panel from 'react-bootstrap/lib/Panel';
@ -97,9 +98,9 @@ const Property = React.createClass({
// In order to set this.state.value from another component
// the state of value should only be set if its not undefined and
// actually references something
if(childInput && typeof childInput.getDOMNode().value !== 'undefined') {
if(childInput && typeof ReactDOM.findDOMNode(childInput).value !== 'undefined') {
this.setState({
value: childInput.getDOMNode().value
value: ReactDOM.findDOMNode(childInput).value
});
// When implementing custom input components, their value isn't exposed like the one
@ -136,7 +137,7 @@ const Property = React.createClass({
// Therefore we have to make sure only to reset the initial value
// of HTML inputs (which we determine by checking if there 'type' attribute matches
// the ones included in AppConstants.possibleInputTypes).
let inputDOMNode = input.getDOMNode();
let inputDOMNode = ReactDOM.findDOMNode(input);
if(inputDOMNode.type && typeof inputDOMNode.type === 'string' &&
AppConstants.possibleInputTypes.indexOf(inputDOMNode.type.toLowerCase()) > -1) {
inputDOMNode.value = this.state.initialValue;
@ -176,10 +177,10 @@ const Property = React.createClass({
// skip the focus of non-input elements
let nonInputHTMLElements = ['pre', 'div'];
if (this.refs.input &&
nonInputHTMLElements.indexOf(this.refs.input.getDOMNode().nodeName.toLowerCase()) > -1 ) {
nonInputHTMLElements.indexOf(ReactDOM.findDOMNode(this.refs.input).nodeName.toLowerCase()) > -1 ) {
return;
}
this.refs.input.getDOMNode().focus();
ReactDOM.findDOMNode(this.refs.input).focus();
this.setState({
isFocused: true
});
@ -201,7 +202,7 @@ const Property = React.createClass({
errors: null,
// also update initialValue in case of the user updating and canceling its actions again
initialValue: this.refs.input.getDOMNode().value
initialValue: ReactDOM.findDOMNode(this.refs.input).value
});
},

View File

@ -1,8 +1,10 @@
'use strict';
import React from 'react';
import ReactDOM from 'react-dom';
import classnames from 'classnames';
let ActionPanel = React.createClass({
propTypes: {
title: React.PropTypes.string,
@ -37,7 +39,7 @@ let ActionPanel = React.createClass({
this.props.onClick();
}
this.refs.input.getDOMNode().focus();
ReactDOM.findDOMNode(this.refs.input).focus();
this.setState({
isFocused: true
});

View File

@ -1,6 +1,7 @@
'use strict';
import React from 'react';
import ReactDOM from 'react-dom';
import SlidesContainerBreadcrumbs from './slides_container_breadcrumbs';
@ -57,7 +58,7 @@ const SlidesContainer = React.createClass({
handleContainerResize() {
this.setState({
// +30 to get rid of the padding of the container which is 15px + 15px left and right
containerWidth: this.refs.containerWrapper.getDOMNode().offsetWidth + 30
containerWidth: ReactDOM.findDOMNode(this.refs.containerWrapper).offsetWidth + 30
});
},

View File

@ -1,6 +1,7 @@
'use strict';
import React from 'react';
import ReactDOM from 'react-dom';
import AppConstants from '../../constants/application_constants';
@ -30,7 +31,7 @@ let FacebookShareButton = React.createClass({
InjectInHeadUtils
.inject(AppConstants.facebook.sdkUrl)
.then(() => { FB.XFBML.parse(this.refs.fbShareButton.getDOMNode().parentElement) });
.then(() => { FB.XFBML.parse(ReactDOM.findDOMNode(this.refs.fbShareButton).parentElement) });
},
shouldComponentUpdate(nextProps) {

View File

@ -1,6 +1,7 @@
'use strict';
import React from 'react';
import ReactDOM from 'react-dom';
import AppConstants from '../../constants/application_constants';
@ -31,7 +32,7 @@ let TwitterShareButton = React.createClass({
loadTwitterButton() {
const { count, counturl, hashtags, size, text, url, via } = this.props;
twttr.widgets.createShareButton(url, this.refs.twitterShareButton.getDOMNode(), {
twttr.widgets.createShareButton(url, ReactDOM.findDOMNode(this.refs.twitterShareButton), {
count,
counturl,
hashtags,

View File

@ -1,6 +1,7 @@
'use strict';
import React from 'react';
import ReactDOM from 'react-dom';
import ProgressBar from 'react-bootstrap/lib/ProgressBar';
import FileDragAndDropDialog from './file_drag_and_drop_dialog';
@ -45,7 +46,7 @@ let FileDragAndDrop = React.createClass({
},
clearSelection() {
this.refs.fileSelector.getDOMNode().value = '';
ReactDOM.findDOMNode(this.refs.fileSelector).value = '';
},
handleDragOver(event) {
@ -122,7 +123,7 @@ let FileDragAndDrop = React.createClass({
evt.initMouseEvent('click', true, true, window, 0, 0, 0, 80, 20, false, false, false, false, 0, null);
}
this.refs.fileSelector.getDOMNode().dispatchEvent(evt);
ReactDOM.findDOMNode(this.refs.fileSelector).dispatchEvent(evt);
}
},

View File

@ -1,6 +1,7 @@
'use strict';
import React from 'react';
import ReactDOM from 'react-dom';
import { displayValidProgressFilesFilter } from '../react_s3_fine_uploader_utils';
import { getLangText } from '../../../utils/lang_utils';
@ -65,7 +66,7 @@ export default function UploadButton({ className = 'btn btn-default btn-sm' } =
},
clearSelection() {
this.refs.fileSelector.getDOMNode().value = '';
ReactDOM.findDOMNode(this.refs.fileSelector).value = '';
},
handleOnClick() {
@ -87,7 +88,7 @@ export default function UploadButton({ className = 'btn btn-default btn-sm' } =
evt.initMouseEvent('click', true, true, window, 0, 0, 0, 80, 20, false, false, false, false, 0, null);
}
evt.stopPropagation();
this.refs.fileSelector.getDOMNode().dispatchEvent(evt);
ReactDOM.findDOMNode(this.refs.fileSelector).dispatchEvent(evt);
}
},

View File

@ -1,6 +1,7 @@
'use strict';
import React from 'react';
import ReactDOM from 'react-dom';
import classNames from 'classnames';
import GlobalNotificationActions from '../actions/global_notification_actions';
@ -48,7 +49,7 @@ let GlobalNotification = React.createClass({
handleContainerResize() {
this.setState({
containerWidth: this.refs.notificationWrapper.getDOMNode().offsetWidth
containerWidth: ReactDOM.findDOMNode(this.refs.notificationWrapper).offsetWidth
});
},

View File

@ -1,6 +1,7 @@
'use strict';
import React from 'react';
import ReactDOM from 'react-dom';
import UserStore from '../../../../../stores/user_store';
import UserActions from '../../../../../actions/user_actions';
@ -136,7 +137,7 @@ let PrizeJurySettings = React.createClass({
handleCreateSuccess(response) {
PrizeJuryActions.fetchJury();
this.displayNotification(response);
this.refs.form.refs.email.refs.input.getDOMNode().value = null;
ReactDOM.findDOMNode(this.refs.form.refs.email.refs.input).value = null;
},
handleActivate(event) {