Unverified Commit 707121c9 authored by Ben Mullins's avatar Ben Mullins Committed by Lee Rowlands
Browse files

Issue #3239509 by hooroomoo, larowlan, bnjmnm, lauriii: Add String.includes...

Issue #3239509 by hooroomoo, larowlan, bnjmnm, lauriii: Add String.includes polyfill to support IE11 and Opera Mini

(cherry picked from commit 0949c10c)
parent c4debe70
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -381,6 +381,11 @@ drupal.states:
    - core/once
    - core/jquery.once.bc

drupal.string.includes:
  version: VERSION
  js:
    misc/polyfills/string.includes.js: { weight: -20 }

drupal.tabbingmanager:
  version: VERSION
  js:
+26 −0
Original line number Diff line number Diff line
/**
 * @file
 * Provides a polyfill for String.includes().
 *
 * This is needed for Internet Explorer 11 and Opera Mini.
 *
 * This has been copied from MDN Web Docs code samples. Code samples in the MDN
 * Web Docs are licensed under CC0.
 *
 * @see https://web.archive.org/web/20210916035058/https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/includes
 * @see https://developer.mozilla.org/en-US/docs/MDN/About#Code_samples_and_snippets
 */
/* eslint-disable strict, lines-around-directive, no-extend-native */
if (!String.prototype.includes) {
  String.prototype.includes = function (search, start) {
    'use strict';

    if (search instanceof RegExp) {
      throw TypeError('first argument must not be a RegExp');
    }
    if (start === undefined) {
      start = 0;
    }
    return this.indexOf(search, start) !== -1;
  };
}
+22 −0
Original line number Diff line number Diff line
/**
* DO NOT EDIT THIS FILE.
* See the following change record for more information,
* https://www.drupal.org/node/2815083
* @preserve
**/

if (!String.prototype.includes) {
  String.prototype.includes = function (search, start) {
    'use strict';

    if (search instanceof RegExp) {
      throw TypeError('first argument must not be a RegExp');
    }

    if (start === undefined) {
      start = 0;
    }

    return this.indexOf(search, start) !== -1;
  };
}
 No newline at end of file
+1 −0
Original line number Diff line number Diff line
@@ -21,5 +21,6 @@ drupal.block.admin:
    - core/drupal.announce
    - core/drupal.debounce
    - core/drupal.dialog.ajax
    - core/drupal.string.includes
    - core/once
    - core/jquery.once.bc
+1 −1
Original line number Diff line number Diff line
@@ -46,7 +46,7 @@
        function toggleBlockEntry(index, label) {
          const $label = $(label);
          const $row = $label.parent().parent();
          const textMatch = $label.text().toLowerCase().indexOf(query) !== -1;
          const textMatch = $label.text().toLowerCase().includes(query);
          $row.toggle(textMatch);
        }

Loading