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

feat: duplicate navigation related APIs to contents.navigationHistory #41752

Merged
merged 12 commits into from
Jun 5, 2024
Prev Previous commit
Next Next commit
fix: add deprecation warnings to webcontents
  • Loading branch information
alicelovescake committed May 28, 2024
commit 438373a49e07a1fe685238b7c2ba005877d4ae06
41 changes: 41 additions & 0 deletions lib/browser/api/web-contents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,47 @@ const loggingEnabled = () => {
return environment.hasVar('ELECTRON_ENABLE_LOGGING') || commandLine.hasSwitch('enable-logging');
};

// Deprecation warnings for navigation related APIs.
WebContents.prototype.canGoBack = function () {
deprecate.warnOnce('webContents.canGoBack', 'webContents.navigationHistory.canGoBack');
return this.canGoBack();
};

WebContents.prototype.canGoForward = function () {
deprecate.warnOnce('webContents.canGoForward', 'webContents.navigationHistory.canGoForward');
return this.canGoForward();
};

WebContents.prototype.canGoToOffset = function (index: number) {
deprecate.warnOnce('webContents.canGoToOffset', 'webContents.navigationHistory.canGoToOffset');
return this.canGoToOffset(index);
};

WebContents.prototype.clearHistory = function () {
deprecate.warnOnce('webContents.clearHistory', 'webContents.navigationHistory.clear');
return this.clearHistory();
};

WebContents.prototype.goBack = function () {
deprecate.warnOnce('webContents.goBack', 'webContents.navigationHistory.goBack');
return this.goBack();
};

WebContents.prototype.goForward = function () {
deprecate.warnOnce('webContents.goForward', 'webContents.navigationHistory.goForward');
return this.goForward();
};

WebContents.prototype.goToIndex = function (index: number) {
deprecate.warnOnce('webContents.goToIndex', 'webContents.navigationHistory.goToIndex');
return this.goToIndex(index);
};

WebContents.prototype.goToOffset = function (index: number) {
deprecate.warnOnce('webContents.goToOffset', 'webContents.navigationHistory.goToOffset');
return this.goToOffset(index);
};

// Add JavaScript wrappers for WebContents class.
WebContents.prototype._init = function () {
const prefs = this.getLastWebPreferences() || {};
Expand Down