I can't see why startsWith was used conditionally here.

It looks like its been supported on all browsers for a very long time:
https://caniuse.com/?search=startsWith

We also already use it several other JS libraries:

- library_async.js
- library_dylink.js
- library_stack_trace.js
- library_webgl.js
This commit is contained in:
Sam Clegg 2021-04-19 15:19:35 -07:00 коммит произвёл GitHub
Родитель b09a949755
Коммит f0c03e0887
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
1 изменённых файлов: 3 добавлений и 10 удалений

Просмотреть файл

@ -4,23 +4,16 @@
* SPDX-License-Identifier: MIT
*/
function hasPrefix(str, prefix) {
return String.prototype.startsWith ?
str.startsWith(prefix) :
str.indexOf(prefix) === 0;
}
// Prefix of data URIs emitted by SINGLE_FILE and related options.
var dataURIPrefix = 'data:application/octet-stream;base64,';
// Indicates whether filename is a base64 data URI.
function isDataURI(filename) {
return hasPrefix(filename, dataURIPrefix);
// Prefix of data URIs emitted by SINGLE_FILE and related options.
return filename.startsWith(dataURIPrefix);
}
var fileURIPrefix = "file://";
// Indicates whether filename is delivered via file protocol (as opposed to http/https)
function isFileURI(filename) {
return hasPrefix(filename, fileURIPrefix);
return filename.startsWith('file://');
}