whatwg / console

Console Standard
https://console.spec.whatwg.org/
Other
269 stars 67 forks source link

Formatter algorithm does not handle having no format specifiers #204

Closed AtkinsSJ closed 1 year ago

AtkinsSJ commented 2 years ago

https://console.spec.whatwg.org/commit-snapshots/6447e9d3cdb01c48094cbaa32d0e5fb1ab74367d/#formatter

Hello! I'm in the process of implementing the console spec in a new browser, and came across some issues with using result in the Formatter algorithm.

Step 4 in the Formatter algorithm asks us to return result:

  1. If target does not have any format specifiers left, return result.

If the first element of args did not contain any format specifiers, then result has no value here. This can occur, since trace(), group() and groupCollapsed() all call Formatter without checking that a format specifier is present.

I think this is a typo, and step 3.8 should be unindented and appear as step 4. However, if no format specifier was found, that would skip the second element of args. So either this needs special handling, or the functions calling Formatter all need to ensure that it does contain a format specifier first, and call Printer otherwise.

terinjokes commented 2 years ago

Thanks for the issue, this does indeed seem like a problem to me. We my want to handle this as a special case in Formatter, then take away the conditional from Logger. But I'll have to double check this doesn't introduce other problems.

domfarolino commented 2 years ago

@AtkinsSJ Are you interested in talking a stab at this?

AtkinsSJ commented 2 years ago

Sure, I'd be happy to!