xiaody / react-lines-ellipsis

Simple multiline ellipsis component for React.JS

Home Page:https://xiaody.github.io/react-lines-ellipsis/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

BasedOn prop is ignored

yanosh-igor opened this issue · comments

BasedOn option is ignored. When I set basedOn to 'letters' it doesn't work. Ir still selects a 'words'.
Here is snipped from code.

 key: 'reflow',
    value: function reflow(props) {
      /* eslint-disable no-control-regex */
      var basedOn = props.basedOn || /^[\x00-\x7F]+$/.test(props.text) ? 'words' : 'letters';
      switch (basedOn) {
        case 'words':
          this.units = props.text.split(/\b|(?=\W)/);
          break;
        case 'letters':
          this.units = Array.from(props.text);
          break;
        default:
          throw new Error('Unsupported options basedOn: ' + basedOn);
      }

If prop basedOn exists then 'words' will be selected. And it doesn't metter what value basedOn will have.
Could you please fix this issue.

Same as #15. Just bumped the version to react-lines-ellipsis@0.10.3.