<commit_before>import React from 'react';

import AlertActions from '../actions/alertActions';
import {t} from '../locale';


const AvatarCropper = React.createClass({
  propTypes: {
    user: React.PropTypes.object.isRequired,
    updateDataUrlState: React.PropTypes.func.isRequired,
    savedDataUrl: React.PropTypes.string
  },

  getInitialState() {
    return {
      mousePosition: {
        pageX: null,
        pageY: null
      },
      resizeDimensions: {
        top: 0,
        left: 0,
        size: 0
      }
    };
  },

  MIN_DIMENSION: 256,

  MAX_DIMENSION: 1024,

  onChange(ev) {
    let file = ev.target.files[0];

    if (!/^image\//.test(file.type))
      return void this.handleError('That is not a supported file type.');

    this.state.objectURL && window.URL.revokeObjectURL(this.state.objectURL);
    this.setState({
      file: file,
      objectURL: window.URL.createObjectURL(file)
    }, () => {<commit_msg>Fix avatar cropper exception when canceling file selection (fixes #3274)<commit_after>import React from 'react';

import AlertActions from '../actions/alertActions';
import {t} from '../locale';


const AvatarCropper = React.createClass({
  propTypes: {
    user: React.PropTypes.object.isRequired,
    updateDataUrlState: React.PropTypes.func.isRequired,
    savedDataUrl: React.PropTypes.string
  },

  getInitialState() {
    return {
      mousePosition: {
        pageX: null,
        pageY: null
      },
      resizeDimensions: {
        top: 0,
        left: 0,
        size: 0
      }
    };
  },

  MIN_DIMENSION: 256,

  MAX_DIMENSION: 1024,

  onChange(ev) {
    /*eslint consistent-return:0*/
    let file = ev.target.files[0];

    if (!file)
      return; // No file selected (e.g. user clicked "cancel")

    if (!/^image\//.test(file.type))
      return void this.handleError('That is not a supported file type.');

    this.state.objectURL && window.URL.revokeObjectURL(this.state.objectURL);
    this.setState({
      file: file,
      objectURL: window.URL.createObjectURL(file)
    }, () => {
{'fraction_non_alphanumeric': 0.13200194836824158, 'fraction_numerical': 0.013151485630784217, 'mean_word_length': 2.6483126110124333, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3953056', 'n_tokens_mistral': 694, 'n_tokens_neox': 654, 'n_words': 145}