<commit_before>import Component from 'flarum/Component';
import icon from 'flarum/helpers/icon';
import extract from 'flarum/utils/extract';

/**
 * The `Badge` component represents a user/discussion badge, indicating some
 * status (e.g. a discussion is stickied, a user is an admin).
 *
 * A badge may have the following special props:
 *
 * - `type` The type of badge this is. This will be used to give the badge a
 *   class name of `Badge--{type}`.
 * - `icon` The name of an icon to show inside the badge.
 *
 * All other props will be assigned as attributes on the badge element.
 */
export default class Badge extends Component {
  view() {
    const attrs = Object.assign({}, this.props);
    const type = extract(attrs, 'type');
    const iconName = extract(attrs, 'icon');

    attrs.className = 'Badge ' + (type ? 'Badge--' + type : '') + ' ' + (attrs.className || '');
    attrs.title = extract(attrs, 'label') || '';

    // Give the badge a unique key so that when badges are displayed together,
    // and then one is added/removed, Mithril will correctly redraw the series
    // of badges.
    attrs.key = attrs.type;

    return (
      <span {...attrs}>
        {iconName ? icon(iconName, {className: 'Badge-icon'}) : m.trust('&nbsp;')}
      </span>
    );
  }

  config(isInitialized) {
    if (isInitialized) return;

    if (this.props.label) this.$().tooltip();
  }
}<commit_msg>Prevent badge tooltips from being cut off<commit_after>import Component from 'flarum/Component';
import icon from 'flarum/helpers/icon';
import extract from 'flarum/utils/extract';

/**
 * The `Badge` component represents a user/discussion badge, indicating some
 * status (e.g. a discussion is stickied, a user is an admin).
 *
 * A badge may have the following special props:
 *
 * - `type` The type of badge this is. This will be used to give the badge a
 *   class name of `Badge--{type}`.
 * - `icon` The name of an icon to show inside the badge.
 *
 * All other props will be assigned as attributes on the badge element.
 */
export default class Badge extends Component {
  view() {
    const attrs = Object.assign({}, this.props);
    const type = extract(attrs, 'type');
    const iconName = extract(attrs, 'icon');

    attrs.className = 'Badge ' + (type ? 'Badge--' + type : '') + ' ' + (attrs.className || '');
    attrs.title = extract(attrs, 'label') || '';

    // Give the badge a unique key so that when badges are displayed together,
    // and then one is added/removed, Mithril will correctly redraw the series
    // of badges.
    attrs.key = attrs.type;

    return (
      <span {...attrs}>
        {iconName ? icon(iconName, {className: 'Badge-icon'}) : m.trust('&nbsp;')}
      </span>
    );
  }

  config(isInitialized) {
    if (isInitialized) return;

    if (this.props.label) this.$().tooltip({container: 'body'});
  }
}
{'fraction_non_alphanumeric': 0.13765323992994746, 'fraction_numerical': 0.0, 'mean_word_length': 3.08, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '3713154', 'n_tokens_mistral': 883, 'n_tokens_neox': 858, 'n_words': 317}