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

[next] null as optional parameter for functions in CanvasRenderingContext2D with CanvasWindingRule #15126

Closed
DartBot opened this issue Nov 17, 2013 · 3 comments
Labels
area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. closed-not-planned Closed as we don't intend to take action on the reported issue library-html

Comments

@DartBot
Copy link

DartBot commented Nov 17, 2013

This issue was originally filed by @denniskaselow


What steps will reproduce the problem?

  1. Run this code as JavaScript
    import 'dart:html';

void main() {
  var canvas = new CanvasElement();
  canvas.context2D.fill(null);
}

What is the expected output? What do you see instead?
Works in Dart but does not work in JS.
When run in JS, following error occurs:
TypeError: Argument 1 of CanvasRenderingContext2D.fill 'null' is not a valid value for enumeration CanvasWindingRule.

What version of the product are you using? On what operating system?
Dart Editor version 1.0.0_r30188 (STABLE)
Dart SDK version 1.0.0.3_r30188

Please provide any additional information below.
I'm not sure if it really is a bug but at least it's a bit of an inconsistency between Dart and JS (error can probably pop up for similar functions). In my case I am delegating a call to fill and just pass the optional parameter without checking for null (easy workaround: I check for null and call the method without a param). Also, no need to bring ?param back ;).

@sethladd
Copy link
Contributor

Added Area-HTML, Triaged labels.

@kevmoo
Copy link
Member

kevmoo commented Apr 7, 2014

Removed Area-HTML label.
Added Area-Library, Library-Html labels.

@alan-knight
Copy link
Contributor

I don't see a way around this without language changes. Dart does not provide us with the arity we were actually called with, and doesn't distinguish null versus undefined. So fill(), fill(null), and fill(null, null) all look identical to the inside of the method. The reason it works is that it's treated as if you called fill(). JavaScript does distinguish the number of arguments, so tries to call it passing in the winding, and fails with it as a null value.


Added NotPlanned label.
Changed the title to: "[next] null as optional parameter for functions in CanvasRenderingContext2D with CanvasWindingRule".

@DartBot DartBot added Type-Defect area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. library-html closed-not-planned Closed as we don't intend to take action on the reported issue labels Jan 20, 2015
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. closed-not-planned Closed as we don't intend to take action on the reported issue library-html
Projects
None yet
Development

No branches or pull requests

4 participants