On Tue, Sep 1, 2009 at 8:07 PM, Maciej Stachowiak <mjs@apple.com> wrote:
instead of var globalScript = new webkitGlobalScript(name, url, loadHandler, errorHandler);
to have this: <webkit-globalscript name='...', src='url', onload=... onerror=...></webkit-globalscript>
The first tag with a specific name that provides a src or inline script or injected with innerText would effectively supply 'initial script'. The later-encountered tags withthe same name would have their initial script ignored and simply connected to the same one. The tag's DOM element would be EventTarget (for load and error) and have a 'context' property to pull the global scope object of the script.
Why is a tag better for this than a constructor or function?
I'm not saying it's better. The tag idea was brought more then once before so I think it is worth considered.I think the motivation behind it is to be able to hook up event handlers before loading ends to be notified when the context is ready. Constructor with callbacks can do the similar thing, imo. Dmitry