1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-22 16:18:08 +02:00

Upstream the changes from: Bug 1339461 - Convert foo.indexOf(...) == -1 to foo.includes() and implement an eslint rule to enforce this

Yet another case where PDF.js code was modified in `mozilla-central` without the changes happening in the GitHub repo first; *sigh*.
If we don't upstream at least the changes in `extensions/firefox/`, any future update of PDF.js in `mozilla-central` will be blocked.

Please see:
 - https://bugzilla.mozilla.org/show_bug.cgi?id=1339461
 - https://hg.mozilla.org/mozilla-central/rev/d5a5ad1dbbf2
This commit is contained in:
Jonas Jenwald 2018-02-04 14:50:58 +01:00
parent 9ac9ef8ef1
commit 712090eff8
9 changed files with 13 additions and 13 deletions

View file

@ -411,7 +411,7 @@ var ChunkedStreamManager = (function ChunkedStreamManagerClosure() {
var beginChunk = this.getBeginChunk(ranges[i].begin);
var endChunk = this.getEndChunk(ranges[i].end);
for (var chunk = beginChunk; chunk < endChunk; ++chunk) {
if (chunksToRequest.indexOf(chunk) < 0) {
if (!chunksToRequest.includes(chunk)) {
chunksToRequest.push(chunk);
}
}

View file

@ -942,7 +942,7 @@ var CMapFactory = (function CMapFactoryClosure() {
} else if (name === 'Identity-V') {
return Promise.resolve(new IdentityCMap(true, 2));
}
if (BUILT_IN_CMAPS.indexOf(name) === -1) {
if (!BUILT_IN_CMAPS.includes(name)) {
return Promise.reject(new Error('Unknown CMap name: ' + name));
}
if (!fetchBuiltInCMap) {

View file

@ -1316,7 +1316,7 @@ var Font = (function FontClosure() {
for (let i = 0; i < numTables; i++) {
let table = readTableEntry(font);
if (VALID_TABLES.indexOf(table.tag) < 0) {
if (!VALID_TABLES.includes(table.tag)) {
continue; // skipping table if it's not a required or optional table
}
if (table.length === 0) {
@ -2113,7 +2113,7 @@ var Font = (function FontClosure() {
if (funcId in ttContext.functionsStackDeltas) {
stack.length += ttContext.functionsStackDeltas[funcId];
} else if (funcId in ttContext.functionsDefined &&
functionsCalled.indexOf(funcId) < 0) {
!functionsCalled.includes(funcId)) {
callstack.push({ data, i, stackTop: stack.length - 1, });
functionsCalled.push(funcId);
pc = ttContext.functionsDefined[funcId];

View file

@ -596,7 +596,7 @@ class ChoiceWidgetAnnotationElement extends WidgetAnnotationElement {
optionElement.textContent = option.displayValue;
optionElement.value = option.exportValue;
if (this.data.fieldValue.indexOf(option.displayValue) >= 0) {
if (this.data.fieldValue.includes(option.displayValue)) {
optionElement.setAttribute('selected', true);
}
@ -628,7 +628,7 @@ class PopupAnnotationElement extends AnnotationElement {
this.container.className = 'popupAnnotation';
if (IGNORE_TYPES.indexOf(this.data.parentType) >= 0) {
if (IGNORE_TYPES.includes(this.data.parentType)) {
return this.container;
}

View file

@ -1131,7 +1131,7 @@ class LoopbackPort {
var buffer;
if ((buffer = value.buffer) && isArrayBuffer(buffer)) {
// We found object with ArrayBuffer (typed array).
var transferable = transfers && transfers.indexOf(buffer) >= 0;
var transferable = transfers && transfers.includes(buffer);
if (value === buffer) {
// Special case when we are faking typed arrays in compatibility.js.
result = value;

View file

@ -229,7 +229,7 @@ class SimpleXMLParser {
}
_decodeXML(text) {
if (text.indexOf('&') < 0) {
if (!text.includes('&')) {
return text;
}