From 358cd0c0965dcd86fdcb3a1291009ad8839fbf68 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Sat, 5 Jan 2019 17:09:44 +0100 Subject: [PATCH] Add a few more `String` polyfills (startsWith, endsWith, padStart, padEnd) --- src/shared/compatibility.js | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/src/shared/compatibility.js b/src/shared/compatibility.js index ff99f9b15..01a2ba701 100644 --- a/src/shared/compatibility.js +++ b/src/shared/compatibility.js @@ -112,6 +112,24 @@ const hasDOM = typeof window === 'object' && typeof document === 'object'; }; })(); +// Provides support for String.prototype.startsWith in legacy browsers. +// Support: IE, Chrome<41 +(function checkStringStartsWith() { + if (String.prototype.startsWith) { + return; + } + require('core-js/fn/string/starts-with'); +})(); + +// Provides support for String.prototype.endsWith in legacy browsers. +// Support: IE, Chrome<41 +(function checkStringEndsWith() { + if (String.prototype.endsWith) { + return; + } + require('core-js/fn/string/ends-with'); +})(); + // Provides support for String.prototype.includes in legacy browsers. // Support: IE, Chrome<41 (function checkStringIncludes() { @@ -223,6 +241,24 @@ const hasDOM = typeof window === 'object' && typeof document === 'object'; } // End of !PDFJSDev.test('CHROME') +// Provides support for String.prototype.padStart in legacy browsers. +// Support: IE, Chrome<57 +(function checkStringPadStart() { + if (String.prototype.padStart) { + return; + } + require('core-js/fn/string/pad-start'); +})(); + +// Provides support for String.prototype.padEnd in legacy browsers. +// Support: IE, Chrome<57 +(function checkStringPadEnd() { + if (String.prototype.padEnd) { + return; + } + require('core-js/fn/string/pad-end'); +})(); + // Provides support for Object.values in legacy browsers. // Support: IE, Chrome<54 (function checkObjectValues() {