Problem/Motivation

In Drupal core, str.indexOf(val) or array.indexOf(val) compare with -1 are already replaced in #3439646: Some of string comparisons should use String.prototype.startsWith() or String.prototype.endsWith() or #3454079: Prefer to use Array.prototype.includes() for some of Array.prototype.indexOf(). Now str.inludes() and array.includes() can use modern browsers so module supporting Drupal 10+ can replace these code.

Proposed resolution

str.strpos(val) or array.indexOf(val) compare with -1 replaces like following list.

  1. str.indexOf(val) !== -1 replaces with str.includes(val)
  2. array.indexOf(val) !== -1 replaces with array.includes(val)

Remaining tasks

TBD

User interface changes

API changes

Data model changes

Release notes snippet

Issue fork charts-3549433

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

tom konda created an issue. See original summary.

tom konda’s picture

Status: Active » Needs work

tom konda’s picture

Status: Needs work » Needs review
nikathone’s picture

Status: Needs review » Reviewed & tested by the community

Thanks @tom konda.

  • andileco committed 83c277b0 on 5.1.x authored by tom konda
    Issue #3549433: Prefer to replace str.indexOf(val) or array.indexOf(val...
andileco’s picture

Status: Reviewed & tested by the community » Fixed

Committed - thank you!

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.