Skip to content

dart:html: Console.log() and its family accept only one argument #19977

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

Open
yutak opened this issue Jul 11, 2014 · 5 comments
Open

dart:html: Console.log() and its family accept only one argument #19977

yutak opened this issue Jul 11, 2014 · 5 comments
Labels
area-web-js Issues related to JavaScript support for Dart Web, including DDC, dart2js, and JS interop. library-html type-enhancement A request for a change that isn't a bug web-libraries Issues impacting dart:html, etc., libraries

Comments

@yutak
Copy link

yutak commented Jul 11, 2014

With JS, I can write something like:

    window.console.log('Debug: ', window, document);

This pretty-prints objects passed in the argument list (instead of
toString()'ed ones).

See https://developer.mozilla.org/en/docs/Web/API/console

The counterpart of Dart, however, only accepts just one Object, and
thus I can't write equivalent code in Dart.

https://api.dartlang.org/apidocs/channels/stable/dartdoc-viewer/dart-dom-html.Console

@anders-sandholm
Copy link
Contributor

Added Area-Library, Library-Html, Triaged labels.

@alan-knight
Copy link
Contributor

I don't understand what's being asked for that can't be done with string interpolation.

   window.console.log(' Debug: $window $document');

It refers to pretty-printing the objects, which from the MDN docs seems like it means printing them as a map in JS. But Dart objects don't have that representation, and just being able to produce it adds runtime overhead that I don't think we'd want to do.


Removed Type-Defect label.
Added Type-Enhancement, NeedsInfo labels.

@yutak
Copy link
Author

yutak commented Jan 16, 2015

For example, type "console.log(document, document, document)" in Chrome's JavaScript
console. You will see three #documents that can be clicked to open, so you can browse
the content of the document tree inside the developer console. This can't be done
with string interpolation.

@alan-knight
Copy link
Contributor

Thanks, that makes sense.


Added Accepted label.

@yutak yutak added Type-Enhancement area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. library-html labels Jan 28, 2015
@kevmoo kevmoo added type-enhancement A request for a change that isn't a bug and removed accepted labels Feb 29, 2016
@luaVolk
Copy link
Contributor

luaVolk commented Dec 14, 2018

Any word on this?
This is also important to print text with CSS styles.

For example in JS i can do:

In Dart the only way I have to do this is to call the method from JS with dart:js.

@vsmenon vsmenon added the area-web-js Issues related to JavaScript support for Dart Web, including DDC, dart2js, and JS interop. label Jul 20, 2019
@sigmundch sigmundch added the web-libraries Issues impacting dart:html, etc., libraries label Oct 25, 2021
@lrhn lrhn removed the area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. label Feb 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-web-js Issues related to JavaScript support for Dart Web, including DDC, dart2js, and JS interop. library-html type-enhancement A request for a change that isn't a bug web-libraries Issues impacting dart:html, etc., libraries
Projects
None yet
Development

No branches or pull requests

8 participants