Skip to content

Commit

Permalink
Replace the cloneObj helper function, in the viewer, with native `O…
Browse files Browse the repository at this point in the history
…bject.assign` (PR 9795 follow-up)
  • Loading branch information
Snuffleupagus committed Jun 27, 2018
1 parent 23545ff commit 788ffba
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 20 deletions.
5 changes: 2 additions & 3 deletions web/pdf_document_properties.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
*/

import {
cloneObj, getPageSizeInches, getPDFFileNameFromURL, isPortraitOrientation,
NullL10n
getPageSizeInches, getPDFFileNameFromURL, isPortraitOrientation, NullL10n
} from './ui_utils';
import { createPromiseCapability } from 'pdfjs-lib';

Expand Down Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions web/pdf_history.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
*/

import {
cloneObj, isValidRotation, parseQueryString, waitOnEventOrTimeout
isValidRotation, parseQueryString, waitOnEventOrTimeout
} from './ui_utils';
import { getGlobalEventBus } from './dom_events';

Expand Down Expand Up @@ -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;
}

Expand Down
6 changes: 2 additions & 4 deletions web/preferences.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
* limitations under the License.
*/

import { cloneObj } from './ui_utils';

let defaultPreferences = null;
function getDefaultPreferences() {
if (!defaultPreferences) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
});
}
Expand Down
11 changes: 0 additions & 11 deletions web/ui_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -842,7 +832,6 @@ export {
VERTICAL_PADDING,
isValidRotation,
isPortraitOrientation,
cloneObj,
PresentationModeState,
RendererType,
TextLayerMode,
Expand Down

0 comments on commit 788ffba

Please sign in to comment.