<commit_before>/* global google */

var React = require('react')
var blacklist = require('blacklist')

module.exports = React.createClass({
  getDefaultProps: function () {
    return {
      // WARNING: if autoPan is enabled, the parent maps props will be overridden
      disableAutoPan: true
    }
  },

  componentWillUnmount: function () {
    if (!this.iw) return

    this.iw.close()
  },

  render: function () {
    var props = this.props
    var options = blacklist(this.props, 'children', 'map', 'open')

    if (props.children) {
      options.content = React.renderToStaticMarkup(props.children)
    }

    // new
    if (!this.iw) {
      this.iw = new google.maps.InfoWindow(options)

    // existing
    } else {
      this.iw.setOptions(options)
    }

    // avoid superfluous map reset
    if (props.map !== this.map) {
      this.map = props.map
    }

    if (props.open) {
      this.iw.open(this.map)

    } else {
      this.iw.close()
    }

    return null
  }<commit_msg>InfoWindow: allow anchor passing<commit_after>/* global google */

var React = require('react')
var blacklist = require('blacklist')

module.exports = React.createClass({
  getDefaultProps: function () {
    return {
      // WARNING: if autoPan is enabled, the parent maps props will be overridden
      disableAutoPan: true
    }
  },

  componentWillUnmount: function () {
    if (!this.iw) return

    this.iw.close()
  },

  render: function () {
    var props = this.props
    var options = blacklist(this.props, 'anchor', 'children', 'map', 'open')

    // TODO
//     if (props.children) {
//       options.content = React.renderToStaticMarkup(props.children)
//     }

    // new
    if (!this.iw) {
      this.iw = new google.maps.InfoWindow(options)

    // existing
    } else {
      this.iw.setOptions(options)
    }

    if (props.open) {
      if (!props.map) return null

      this.iw.open(props.map, props.anchor)

    } else {
      this.iw.close()
    }

    return null
  }
{'fraction_non_alphanumeric': 0.134470647265429, 'fraction_numerical': 0.0, 'mean_word_length': 2.3512605042016808, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '3252916', 'n_tokens_mistral': 646, 'n_tokens_neox': 622, 'n_words': 149}