Skip to content

Commit

Permalink
Merge pull request #157 from nikgraf/fix-text-input-server-rendering
Browse files Browse the repository at this point in the history
fix(TextInput): prevent accessing the DOM in case it is not there
  • Loading branch information
nikgraf committed Jul 28, 2015
2 parents 996f487 + cd2cbbd commit 3732732
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/utils/calculate-textarea-height.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { canUseDOM } from 'react/lib/ExecutionEnvironment';

let hiddenTextarea;
const computedStyleCache = {};
const hiddenTextareaStyle = 'height:0;visibility:hidden;overflow:hidden;position:absolute;z-index:-1000;top:0;right:0';
Expand Down Expand Up @@ -50,6 +52,8 @@ function calculateStyling(node) {
* is cached to improve performance.
*/
export default function(textareaElement, textareaValue) {
if (!canUseDOM) { return 0; }

if (!hiddenTextarea) {
hiddenTextarea = document.createElement('textarea');
document.body.appendChild(hiddenTextarea);
Expand Down

0 comments on commit 3732732

Please sign in to comment.