{"size": 1045, "ext": "js", "max_stars_repo_path": "src/common/shim/marionette.region.shim.js", "max_stars_repo_name": "MeoMix/jspm-marionette-boilerplate", "max_stars_repo_stars_event_min_datetime": "2016-01-04T21:46:20.000Z", "max_stars_repo_stars_event_max_datetime": "2017-06-29T00:25:17.000Z", "max_issues_repo_path": "src/common/shim/marionette.region.shim.js", "max_issues_repo_name": "MeoMix/jspm-marionette-boilerplate", "max_issues_repo_issues_event_min_datetime": "2016-01-04T21:33:29.000Z", "max_issues_repo_issues_event_max_datetime": "2017-08-15T01:41:56.000Z", "max_forks_repo_path": "src/common/shim/marionette.region.shim.js", "max_forks_repo_name": "MeoMix/jspm-marionette-boilerplate", "max_forks_repo_forks_event_min_datetime": "2016-01-04T22:48:53.000Z", "max_forks_repo_forks_event_max_datetime": "2019-11-22T10:28:25.000Z"}
{"max_stars_count": 21, "max_issues_count": 3, "max_forks_count": 5, "avg_line_length": 34.8333333333, "max_line_length": 77, "alphanum_fraction": 0.7186602871}
﻿// All regions should be tagged with a "data-region=name" attribute.
// Make the lookup of regions by their data-region attribute implicit.
import _ from 'lodash';
import { Region, Error } from 'marionette';

Region.buildRegion = function(regionConfig, DefaultRegionClass) {
  if (_.isString(regionConfig)) {
    regionConfig = `[data-region=${regionConfig}]`;
    return this._buildRegionFromSelector(regionConfig, DefaultRegionClass);
  }

  if (regionConfig.selector || regionConfig.el || regionConfig.regionClass) {
    if (regionConfig.selector) {
      regionConfig.selector = `[data-region=${regionConfig.selector}]`;
    }
    if (regionConfig.el) {
      regionConfig.el = `[data-region=${regionConfig.el}]`;
    }
    return this._buildRegionFromObject(regionConfig, DefaultRegionClass);
  }

  if (_.isFunction(regionConfig)) {
    return this._buildRegionFromRegionClass(regionConfig);
  }

  throw new Error({
    message: 'Improper region configuration type.',
    url: 'marionette.region.html#region-configuration-types'
  });
};