Merge pull request #9849 from Snuffleupagus/rm-cloneObj
Replace the `cloneObj` helper function, in the viewer, with native `Object.assign` (PR 9795 follow-up)
This commit is contained in:
commit
5e40f04153
@ -14,8 +14,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import {
|
import {
|
||||||
cloneObj, getPageSizeInches, getPDFFileNameFromURL, isPortraitOrientation,
|
getPageSizeInches, getPDFFileNameFromURL, isPortraitOrientation, NullL10n
|
||||||
NullL10n
|
|
||||||
} from './ui_utils';
|
} from './ui_utils';
|
||||||
import { createPromiseCapability } from 'pdfjs-lib';
|
import { createPromiseCapability } from 'pdfjs-lib';
|
||||||
|
|
||||||
@ -161,7 +160,7 @@ class PDFDocumentProperties {
|
|||||||
if (fileSize === this.fieldData['fileSize']) {
|
if (fileSize === this.fieldData['fileSize']) {
|
||||||
return; // The fileSize has already been correctly set.
|
return; // The fileSize has already been correctly set.
|
||||||
}
|
}
|
||||||
let data = cloneObj(this.fieldData);
|
let data = Object.assign(Object.create(null), this.fieldData);
|
||||||
data['fileSize'] = fileSize;
|
data['fileSize'] = fileSize;
|
||||||
|
|
||||||
freezeFieldData(data);
|
freezeFieldData(data);
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import {
|
import {
|
||||||
cloneObj, isValidRotation, parseQueryString, waitOnEventOrTimeout
|
isValidRotation, parseQueryString, waitOnEventOrTimeout
|
||||||
} from './ui_utils';
|
} from './ui_utils';
|
||||||
import { getGlobalEventBus } from './dom_events';
|
import { getGlobalEventBus } from './dom_events';
|
||||||
|
|
||||||
@ -303,7 +303,7 @@ class PDFHistory {
|
|||||||
}
|
}
|
||||||
let position = this._position;
|
let position = this._position;
|
||||||
if (temporary) {
|
if (temporary) {
|
||||||
position = cloneObj(this._position);
|
position = Object.assign(Object.create(null), this._position);
|
||||||
position.temporary = true;
|
position.temporary = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,8 +13,6 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { cloneObj } from './ui_utils';
|
|
||||||
|
|
||||||
let defaultPreferences = null;
|
let defaultPreferences = null;
|
||||||
function getDefaultPreferences() {
|
function getDefaultPreferences() {
|
||||||
if (!defaultPreferences) {
|
if (!defaultPreferences) {
|
||||||
@ -60,7 +58,7 @@ class BasePreferences {
|
|||||||
configurable: false,
|
configurable: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
this.prefs = cloneObj(defaults);
|
this.prefs = Object.assign(Object.create(null), defaults);
|
||||||
return this._readFromStorage(defaults);
|
return this._readFromStorage(defaults);
|
||||||
}).then((prefObj) => {
|
}).then((prefObj) => {
|
||||||
if (prefObj) {
|
if (prefObj) {
|
||||||
@ -96,7 +94,7 @@ class BasePreferences {
|
|||||||
*/
|
*/
|
||||||
reset() {
|
reset() {
|
||||||
return this._initializedPromise.then(() => {
|
return this._initializedPromise.then(() => {
|
||||||
this.prefs = cloneObj(this.defaults);
|
this.prefs = Object.assign(Object.create(null), this.defaults);
|
||||||
return this._writeToStorage(this.defaults);
|
return this._writeToStorage(this.defaults);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -611,16 +611,6 @@ function isPortraitOrientation(size) {
|
|||||||
return size.width <= size.height;
|
return size.width <= size.height;
|
||||||
}
|
}
|
||||||
|
|
||||||
function cloneObj(obj) {
|
|
||||||
let result = Object.create(null);
|
|
||||||
for (let i in obj) {
|
|
||||||
if (Object.prototype.hasOwnProperty.call(obj, i)) {
|
|
||||||
result[i] = obj[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
const WaitOnType = {
|
const WaitOnType = {
|
||||||
EVENT: 'event',
|
EVENT: 'event',
|
||||||
TIMEOUT: 'timeout',
|
TIMEOUT: 'timeout',
|
||||||
@ -842,7 +832,6 @@ export {
|
|||||||
VERTICAL_PADDING,
|
VERTICAL_PADDING,
|
||||||
isValidRotation,
|
isValidRotation,
|
||||||
isPortraitOrientation,
|
isPortraitOrientation,
|
||||||
cloneObj,
|
|
||||||
PresentationModeState,
|
PresentationModeState,
|
||||||
RendererType,
|
RendererType,
|
||||||
TextLayerMode,
|
TextLayerMode,
|
||||||
|
Loading…
Reference in New Issue
Block a user