- From: Maciej Stachowiak <mjs@apple.com>
- Date: Wed, 28 Dec 2005 04:09:42 -0700
- To: www-svg@w3c.org
SVG Tiny 1.2 uses XML Events syntax, and does not support the event
handler attributes as in SVG 1.1.
Here's an example from the spec:
<rect x="10" y="20" width="10" height="20" fill="red">
<handler type="application/ecmascript" ev:event="ev:click">
var myRect = evt.target;
var width = myRect.getFloatTrait("width"));
myRect.setFloatTrait("width", (width+10));
</handler>
</rect>
With an onclick handler, and taking advantage of the fact that inline
event handlers have the DOM object for the current element in scope,
this could be written as:
<rect x="10" y="20" width="10" height="20" fill="red"
onclick="var width = getFloatTrait('width'); setFloatTrait
('width', (width+10));" />
This is easier to author, more concise, and likely to be more compact
in memory at runtime (it saves one element, and one attribute, makes
the JS code simpler, and removes the need to store the text contents
of the handler for full DOM implementations). It seems that for a
Tiny spec that is concerned ebough about footprint to leave out text
nodes and non-trait attributes on SVG elements, this is needless bloat.
XML Events do make it easier to do obscure things. Like connect Java
event handlers, or connect an event handler to an element far from
the element in the document. But these things are already possible
using the DOM API.
What is the reason, therefore, for dropping inline event handler
attributes and replacing them with XML Events?
I recommend bringing back the inline event handler attributes.
I also recommend removing the altered subset of XML Events, since the
novel functionality they provide is obscure and could just as well be
done through script.
Regards,
Maciej
Received on Wednesday, 28 December 2005 11:11:16 UTC