IE8 problem when used with jQuery

223 views
Skip to first unread message

Ole Laursen

unread,
Apr 15, 2009, 2:01:25 PM4/15/09
to google-excanvas
Hi!

I got a bug report some time ago with Excanvas and IE8 when a canvas
is created and manipulated inside a jQuery document ready handler.
Here's the report with analysis:

http://code.google.com/p/flot/issues/detail?id=133

The problem appears to be that G_vmlCanvasManager (which is needed to
add a canvas dynamically) is not properly setup until after init_ is
run. And init_ is run with an onreadystatechange event handler which
according the reporter is too late in IE8 standards mode (i.e. the
jQuery document ready handler is run before it).

Wouldn't it be possible to run the namespace and stylesheet changes
immediately so only the init element loop

var els = doc.getElementsByTagName
('canvas');
for (var i = 0; i < els.length; i++)
{
this.initElement(els
[i]);
}

is deferred to onreadystatechange?

I've just tested it and it seems to work in IE6. With all the uses
I've seen of excanvas, it seems harmless?


Ole

Steve Clay

unread,
Apr 15, 2009, 3:01:35 PM4/15/09
to google-...@googlegroups.com
Ole Laursen wrote:
> The problem appears to be that G_vmlCanvasManager (which is needed to
> add a canvas dynamically) is not properly setup until after init_ is
> run. And init_ is run with an onreadystatechange event handler which
> according the reporter is too late in IE8 standards mode

Hmm, unless every JS library switches to using onreadystatechange for
IE8 (or users poll until their canvas elements have getContext), this
could become a big problem, no?

Could we allow the user to call init_ and make sure it only runs once?

--
Steve Clay
http://mrclay.org/

Ole Laursen

unread,
Apr 28, 2009, 1:34:42 PM4/28/09
to google-excanvas
On Apr 15, 9:01 pm, Steve Clay <st...@mrclay.org> wrote:
> Ole Laursen wrote:
> > The problem appears to be that G_vmlCanvasManager (which is needed to
> > add a canvas dynamically) is not properly setup until after init_ is
> > run. And init_ is run with an onreadystatechange event handler which
> > according the reporter is too late in IE8 standards mode
>
> Hmm, unless every JS library switches to using onreadystatechange for
> IE8 (or users poll until their canvas elements have getContext), this
> could become a big problem, no?

Yes. It remains a problem with statically generated canvases, the
whole emulation without you doing anything breaks down. My idea only
works with dynamically generated canvases where you have to init the
elements yourself anyway.

> Could we allow the user to call init_ and make sure it only runs once?

I don't think the latter is a problem, it looks idempotent to me. OK,
so actually it might be a question of just calling init_ before using
any canvas stuff. It's already public.

I've opened an issue here, the docs should mention it:

http://code.google.com/p/explorercanvas/issues/detail?id=30


Ole
Reply all
Reply to author
Forward
0 new messages