1
0
mirror of https://github.com/videojs/video.js.git synced 2024-11-24 08:42:25 +02:00

@misteroneill fixed logging issues on IE by separating fn.apply and stringify checks. closes #3444

This commit is contained in:
Pat O'Neill 2016-07-20 16:47:54 -04:00 committed by Gary Katsevman
parent 4b4954ef4d
commit 5b15feb5af
2 changed files with 10 additions and 6 deletions

View File

@ -28,6 +28,7 @@ CHANGELOG
* @OwenEdwards fixed caption settings dialog labels for accessibility ([view](https://github.com/videojs/video.js/pull/3281))
* @OwenEdwards removed spurious head tags in the simple-embed example ([view](https://github.com/videojs/video.js/pull/3438))
* @ntadej added a null check to errorDisplay usage ([view](https://github.com/videojs/video.js/pull/3440))
* @misteroneill fixed logging issues on IE by separating fn.apply and stringify checks ([view](https://github.com/videojs/video.js/pull/3444))
--------------------

View File

@ -38,11 +38,10 @@ export const logByType = (type, args, stringify = !!IE_VERSION && IE_VERSION < 1
// add console prefix after adding to history
args.unshift('VIDEOJS:');
// Old IE versions do not allow .apply() for some/all console method(s). And
// IEs previous to 11 log objects uselessly as "[object Object]"; so, JSONify
// objects and arrays for those less-capable browsers.
if (!fn.apply || stringify) {
fn(args.map(a => {
if (stringify) {
args = args.map(a => {
if (a && typeof a === 'object' || Array.isArray(a)) {
try {
return JSON.stringify(a);
@ -52,11 +51,15 @@ export const logByType = (type, args, stringify = !!IE_VERSION && IE_VERSION < 1
// Cast to string before joining, so we get null and undefined explicitly
// included in output (as we would in a modern console).
return String(a);
}).join(' '));
}).join(' ');
}
// Default hanlding for modern consoles.
// Old IE versions do not allow .apply() for console methods (they are
// reported as objects rather than functions).
if (!fn.apply) {
fn(args);
} else {
fn.apply(console, args);
fn[Array.isArray(args) ? 'apply' : 'call'](console, args);
}
};