<commit_before>import LeaderLine from 'leader-line';
import React from 'react';

function shimPointAnchor (point) {
  return point instanceof Element
    ? LeaderLine.pointAnchor( point, { x: 0, y: 0 } )
    : LeaderLine.pointAnchor( document.body, point )
    ;
}

export default class Line extends React.Component {
  componentWillUnmount () {
    if (this.line) {
      const { svg } = this.line.getProps();
      const { parentNode } = svg;

      if (parentNode)
        parentNode.removeChild(svg);

      this.line.remove();
    }
  }

  initLine() {
    const { start, end } = this.props;
    const startPoint = shimPointAnchor(start);
    const endPoint = shimPointAnchor(end);

    this.line = new LeaderLine({
      start: startPoint,
      end: endPoint,
      path: 'fluid',
      dash: true,
    });

    const { svg } = this.line.getProps();
    const { parentNode } = this.mockSvg;
    svg.leaderLine = this.line;

    if (parentNode)
      parentNode.appendChild(svg);

    if (typeof(this.props.onLoad) === 'function')
      this.props.onLoad(this.line);
  }

  shouldComponentUpdate (nextProps) {
    if (!this.line && this.mockSvg && this.props.start && this.props.end) {
      this.initLine();
      return false;
    }

    if (this.line) {

      if (this.props.start != nextProps.start) {
        this.line.start = shimPointAnchor(nextProps.start);
      }

      if (this.props.end != nextProps.end) {
        this.line.end = shimPointAnchor(nextProps.end);
      }

      this.line.position(false);
    }

    return false;
  }


  render() {<commit_msg>Use disableViewBox option<commit_after>import LeaderLine from 'leader-line';
import React from 'react';

function shimPointAnchor (point) {
  return point instanceof Element
    ? LeaderLine.pointAnchor( point, { x: 0, y: 0 } )
    : LeaderLine.pointAnchor( document.body, point )
    ;
}

export default class Line extends React.Component {
  componentWillUnmount () {
    if (this.line) {
      const { svg } = this.line.getProps();
      const { parentNode } = svg;

      if (parentNode)
        parentNode.removeChild(svg);

      this.line.remove();
    }
  }

  initLine() {
    const { start, end } = this.props;
    const startPoint = shimPointAnchor(start);
    const endPoint = shimPointAnchor(end);

    this.line = new LeaderLine({
      start: startPoint,
      end: endPoint,
      path: 'fluid',
      dash: true,
      disableViewBox: true,
    });

    const { svg } = this.line.getProps();
    const { parentNode } = this.mockSvg;
    svg.leaderLine = this.line;

    if (parentNode)
      parentNode.appendChild(svg);

    if (typeof(this.props.onLoad) === 'function')
      this.props.onLoad(this.line);
  }

  shouldComponentUpdate (nextProps) {
    if (!this.line && this.mockSvg && this.props.start && this.props.end) {
      this.initLine();
      return false;
    }

    if (this.line) {

      if (this.props.start != nextProps.start) {
        this.line.start = shimPointAnchor(nextProps.start);
      }

      if (this.props.end != nextProps.end) {
        this.line.end = shimPointAnchor(nextProps.end);
      }

      this.line.position();
    }

    return false;
  }


  render() {
{'fraction_non_alphanumeric': 0.13333333333333333, 'fraction_numerical': 0.0012519561815336462, 'mean_word_length': 2.539313399778516, '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': '5690794', 'n_tokens_mistral': 1053, 'n_tokens_neox': 1014, 'n_words': 216}