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

fix(android): don't patch console object #1991

Merged
merged 1 commit into from
Sep 25, 2019
Merged
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
21 changes: 10 additions & 11 deletions core/native-bridge.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@
win.console.warn('Advance console logging disabled.')
}

// patch window.console and store original console fns
var orgConsole = {};
// patch window.console on iOS and store original console fns
var orgConsole = capacitor.isIOS ? {} : win.console;

// list log functions bridged to native log
var bridgedLevels = {
Expand All @@ -66,12 +66,11 @@
trace: true,
warn: true,
};

Object.keys(win.console).forEach(function (level) {
if (typeof win.console[level] === 'function') {
// loop through all the console functions and keep references to the original
orgConsole[level] = win.console[level];
if (capacitor.isIOS) {
if (capacitor.isIOS) {
Object.keys(win.console).forEach(function (level) {
if (typeof win.console[level] === 'function') {
// loop through all the console functions and keep references to the original
orgConsole[level] = win.console[level];
win.console[level] = function capacitorConsole() {
var msgs = Array.prototype.slice.call(arguments);

Expand Down Expand Up @@ -102,8 +101,8 @@
}
};
}
}
});
});
}

function addLegacyHandlers(win) {
win.navigator.app = {
Expand Down Expand Up @@ -348,7 +347,7 @@
capacitor.handleError = function(error) {
console.error(error);
}

capacitor.handleWindowError = function (msg, url, lineNo, columnNo, error) {
var string = msg.toLowerCase();
var substring = "script error";
Expand Down