From 1a600b0674da34ff515c785b8c779779ec248301 Mon Sep 17 00:00:00 2001 From: Richard van der Hoff Date: Wed, 27 Jul 2016 11:38:04 +0100 Subject: [PATCH 1/2] Stop the Avatar classes setting properties on s React apparently now checks the properties which are set on DOM elements, and grumbles noisily about unexpected ones. Update BaseAvatar and RoomAvatar so that they don't set unrelated properties on the DOM elements. --- src/components/views/avatars/BaseAvatar.js | 26 ++++++++++++---------- src/components/views/avatars/RoomAvatar.js | 8 ++++--- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/src/components/views/avatars/BaseAvatar.js b/src/components/views/avatars/BaseAvatar.js index 66f8e27b88..08d7965455 100644 --- a/src/components/views/avatars/BaseAvatar.js +++ b/src/components/views/avatars/BaseAvatar.js @@ -133,32 +133,34 @@ module.exports = React.createClass({ }, render: function() { - var name = this.props.name; - var imageUrl = this.state.imageUrls[this.state.urlsIndex]; + const {name, idName, title, url, urls, width, height, resizeMethod, + defaultToInitialLetter, + ...otherProps} = this.props; + if (imageUrl === this.state.defaultImageUrl) { - var initialLetter = emojifyText(this._getInitialLetter(this.props.name)); + var initialLetter = emojifyText(this._getInitialLetter(name)); return ( - + + alt="" title={title} onError={this.onError} + width={width} height={height} /> ); } return ( + width={width} height={height} + title={title} alt="" + {...otherProps} /> ); } }); diff --git a/src/components/views/avatars/RoomAvatar.js b/src/components/views/avatars/RoomAvatar.js index 129c68ff1b..dcb25eff61 100644 --- a/src/components/views/avatars/RoomAvatar.js +++ b/src/components/views/avatars/RoomAvatar.js @@ -126,11 +126,13 @@ module.exports = React.createClass({ render: function() { var BaseAvatar = sdk.getComponent("avatars.BaseAvatar"); - var roomName = this.props.room ? this.props.room.name : this.props.oobData.name; + var {room, oobData, ...otherProps} = this.props; + + var roomName = room ? room.name : oobData.name; return ( - ); } From 39ae8c6e46a3563dd69235081d3d9e4e334ed164 Mon Sep 17 00:00:00 2001 From: Richard van der Hoff Date: Wed, 27 Jul 2016 15:41:24 +0100 Subject: [PATCH 2/2] formatting PR feedback --- src/components/views/avatars/BaseAvatar.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/components/views/avatars/BaseAvatar.js b/src/components/views/avatars/BaseAvatar.js index 08d7965455..f0a36c6608 100644 --- a/src/components/views/avatars/BaseAvatar.js +++ b/src/components/views/avatars/BaseAvatar.js @@ -135,9 +135,11 @@ module.exports = React.createClass({ render: function() { var imageUrl = this.state.imageUrls[this.state.urlsIndex]; - const {name, idName, title, url, urls, width, height, resizeMethod, - defaultToInitialLetter, - ...otherProps} = this.props; + const { + name, idName, title, url, urls, width, height, resizeMethod, + defaultToInitialLetter, + ...otherProps + } = this.props; if (imageUrl === this.state.defaultImageUrl) { var initialLetter = emojifyText(this._getInitialLetter(name));