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:
Tim van der Meij 2018-06-27 23:00:27 +02:00 committed by GitHub
commit 5e40f04153
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 6 additions and 20 deletions

View File

@ -14,8 +14,7 @@
*/
import {
cloneObj, getPageSizeInches, getPDFFileNameFromURL, isPortraitOrientation,
NullL10n
getPageSizeInches, getPDFFileNameFromURL, isPortraitOrientation, NullL10n
} from './ui_utils';
import { createPromiseCapability } from 'pdfjs-lib';
@ -161,7 +160,7 @@ class PDFDocumentProperties {
if (fileSize === this.fieldData['fileSize']) {
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;
freezeFieldData(data);

View File

@ -14,7 +14,7 @@
*/
import {
cloneObj, isValidRotation, parseQueryString, waitOnEventOrTimeout
isValidRotation, parseQueryString, waitOnEventOrTimeout
} from './ui_utils';
import { getGlobalEventBus } from './dom_events';
@ -303,7 +303,7 @@ class PDFHistory {
}
let position = this._position;
if (temporary) {
position = cloneObj(this._position);
position = Object.assign(Object.create(null), this._position);
position.temporary = true;
}

View File

@ -13,8 +13,6 @@
* limitations under the License.
*/
import { cloneObj } from './ui_utils';
let defaultPreferences = null;
function getDefaultPreferences() {
if (!defaultPreferences) {
@ -60,7 +58,7 @@ class BasePreferences {
configurable: false,
});
this.prefs = cloneObj(defaults);
this.prefs = Object.assign(Object.create(null), defaults);
return this._readFromStorage(defaults);
}).then((prefObj) => {
if (prefObj) {
@ -96,7 +94,7 @@ class BasePreferences {
*/
reset() {
return this._initializedPromise.then(() => {
this.prefs = cloneObj(this.defaults);
this.prefs = Object.assign(Object.create(null), this.defaults);
return this._writeToStorage(this.defaults);
});
}

View File

@ -611,16 +611,6 @@ function isPortraitOrientation(size) {
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 = {
EVENT: 'event',
TIMEOUT: 'timeout',
@ -842,7 +832,6 @@ export {
VERTICAL_PADDING,
isValidRotation,
isPortraitOrientation,
cloneObj,
PresentationModeState,
RendererType,
TextLayerMode,