Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace the cloneObj helper function, in the viewer, with native Object.assign (PR 9795 follow-up) #9849

Merged
merged 1 commit into from
Jun 27, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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