W3C home > Mailing lists > Public > whatwg@whatwg.org > December 2009

[whatwg] Canvas.cloneNode()

From: Michael A. Puls II <shadow2531@gmail.com>
Date: Thu, 10 Dec 2009 12:15:10 -0500
Message-ID: <op.u4qfjkbc1ejg13@sandra-svwliu01>
On Thu, 10 Dec 2009 10:38:32 -0500, Ian Hickson <ian at hixie.ch> wrote:

> On Thu, 10 Dec 2009, Michael A. Puls II wrote:
>>
>> I don't know canvas stuff that well. What's the proper way to patch  
>> cloneNode
>> to do a full copy?
>>
>> I think something like the following, but maybe you know better.
>>
>> (function() {
>>     var oldCloneNode = HTMLCanvasElement.prototype.cloneNode;
>>     HTMLCanvasElement.prototype.cloneNode = function(deep) {
>>         var copy = oldCloneNode.call(this, deep);
>>         var copy_ctx = copy.getContext("2d");
>>         copy_ctx.drawImage(this, 0, 0, this.width, this.height);
>>         return copy;
>>     };
>> })();
>
> Looks right to me, though generally I would discourage this style of
> programming as it makes it quite hard for people to maintain unless they
> are very familiar with the codebase.

OK. Thanks

-- 
Michael
Received on Thursday, 10 December 2009 09:15:10 UTC

This archive was generated by hypermail 2.3.1 : Monday, 13 April 2015 23:08:54 UTC