W3C home > Mailing lists > Public > public-html-bugzilla@w3.org > November 2010

[Bug 11172] wouldn't it be better to return the context handler instead of void, making "context.moveTo(x1,y1).lineTo(x2,y2).lineTo..." possible and easier?

From: <bugzilla@jessica.w3.org>
Date: Mon, 01 Nov 2010 20:00:31 +0000
To: public-html-bugzilla@w3.org
Message-Id: <E1PD0YR-0003Aw-De@jessica.w3.org>
http://www.w3.org/Bugs/Public/show_bug.cgi?id=11172

--- Comment #3 from Aryeh Gregor <Simetrical+w3cbug@gmail.com> 2010-11-01 20:00:30 UTC ---
This is nice in jQuery because it sometimes lets you avoid naming extra
variables, e.g. (actual code sample I was just looking at)

  $("body").append("<script></script>").attr("src", foo);

rather than

  var script = document.createElement("script");
  script.src = foo;
  document.body.appendChild(script);

which is necessary when using DOM methods because "script.src = foo" and the
equivalent setAttribute() call don't return the element they're operating on,
so you need an explicit temporary variable.  But almost any real-world canvas
use is going to want to keep around a context handler anyway, so it doesn't
look like there's any gain here.  (Although I don't see the harm either.)

-- 
Configure bugmail: http://www.w3.org/Bugs/Public/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
Received on Monday, 1 November 2010 20:00:33 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 1 November 2010 20:00:33 GMT