JakeChampion/polyfill-library

Kinda logic bug with console polyfilling

juliyvchirkov opened this issue · 2 comments

Bug report

console methods for the moment are polyfilled with noops this way

if (!('console' in self && 'exception' in self.console)) {
    console.exception = function () {};
}

if (!('console' in self && 'markTimeline' in self.console)) {
    console.markTimeline = function () {};
}

if (!('console' in self && 'timeline' in self.console)) {
    console.timeline = function () {};
}

if (!('console' in self && 'timelineEnd' in self.console)) {
    console.timelineEnd = function () {};
}

Seems, if there's no 'console' in self, the above code will throw

Thank you @juliyvchirkov for reporting this.

All these polyfills depend on the general polyfill for console :
https://github.com/Financial-Times/polyfill-library/blob/master/polyfills/console/timeline/config.toml#L2

So if everything is working as intended this code should never throw.


Did you encounter a scenario where it does throw?

Got it, thanks a lot. I.e. if there's no 'console' in self, the console object anyway will be created first before applying methods polyfills. Neatly designed.