[whatwg] Canvas.cloneNode()
Michael A. Puls II
shadow2531 at gmail.com
Thu Dec 10 09:15:10 PST 2009
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
More information about the whatwg
mailing list