From af8e88d00ba983e77a8cae0c9d27c72fae8215c7 Mon Sep 17 00:00:00 2001 From: Tim van der Meij Date: Sun, 10 Jun 2018 19:59:03 +0200 Subject: [PATCH] Replace `Util.extendObj` by `Object.assign` --- src/core/operator_list.js | 6 ++---- src/display/api.js | 4 ++-- src/display/text_layer.js | 3 +-- src/shared/compatibility.js | 9 +++++++++ src/shared/util.js | 6 ------ 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/core/operator_list.js b/src/core/operator_list.js index 7b5767968..d9502f9c9 100644 --- a/src/core/operator_list.js +++ b/src/core/operator_list.js @@ -13,9 +13,7 @@ * limitations under the License. */ -import { - ImageKind, OPS, Util -} from '../shared/util'; +import { ImageKind, OPS } from '../shared/util'; var QueueOptimizer = (function QueueOptimizerClosure() { function addState(parentState, pattern, checkFn, iterateFn, processFn) { @@ -612,7 +610,7 @@ var OperatorList = (function OperatorListClosure() { }, addOpList(opList) { - Util.extendObj(this.dependencies, opList.dependencies); + Object.assign(this.dependencies, opList.dependencies); for (var i = 0, ii = opList.length; i < ii; i++) { this.addOp(opList.fnArray[i], opList.argsArray[i]); } diff --git a/src/display/api.js b/src/display/api.js index 397cbb048..f88d99c85 100644 --- a/src/display/api.js +++ b/src/display/api.js @@ -18,7 +18,7 @@ import { assert, createPromiseCapability, getVerbosityLevel, info, InvalidPDFException, isArrayBuffer, isSameOrigin, MissingPDFException, NativeImageDecoding, PasswordException, setVerbosityLevel, shadow, stringToBytes, - UnexpectedResponseException, UnknownErrorException, unreachable, Util, warn + UnexpectedResponseException, UnknownErrorException, unreachable, warn } from '../shared/util'; import { DOMCanvasFactory, DOMCMapReaderFactory, DummyStatTimer, loadScript, @@ -1074,7 +1074,7 @@ var PDFPageProxy = (function PDFPageProxyClosure() { resolve(textContent); return; } - Util.extendObj(textContent.styles, value.styles); + Object.assign(textContent.styles, value.styles); textContent.items.push(...value.items); pump(); }, reject); diff --git a/src/display/text_layer.js b/src/display/text_layer.js index f98930e8e..879d84548 100644 --- a/src/display/text_layer.js +++ b/src/display/text_layer.js @@ -578,10 +578,9 @@ var renderTextLayer = (function renderTextLayerClosure() { return; } - Util.extendObj(styleCache, value.styles); + Object.assign(styleCache, value.styles); this._processItems(value.items, styleCache); pump(); - }, capability.reject); }; diff --git a/src/shared/compatibility.js b/src/shared/compatibility.js index 5a4911357..6578c2b11 100644 --- a/src/shared/compatibility.js +++ b/src/shared/compatibility.js @@ -109,6 +109,15 @@ const hasDOM = typeof window === 'object' && typeof document === 'object'; require('core-js/fn/array/includes'); })(); +// Provides support for Object.assign in legacy browsers. +// Support: IE +(function checkObjectAssign() { + if (Object.assign) { + return; + } + require('core-js/fn/object/assign'); +})(); + // Provides support for Math.log2 in legacy browsers. // Support: IE, Chrome<38 (function checkMathLog2() { diff --git a/src/shared/util.js b/src/shared/util.js index cd650d902..19a331f67 100644 --- a/src/shared/util.js +++ b/src/shared/util.js @@ -886,12 +886,6 @@ var Util = (function UtilClosure() { return (lowerCase ? romanStr.toLowerCase() : romanStr); }; - Util.extendObj = function extendObj(obj1, obj2) { - for (var key in obj2) { - obj1[key] = obj2[key]; - } - }; - Util.inherit = function Util_inherit(sub, base, prototype) { sub.prototype = Object.create(base.prototype); sub.prototype.constructor = sub;