Re: [SVGMobile12] SVGT12-207: Conformance to uDOM

* Jeff Schiller wrote:
><svg ...>
><g xml:id="button" fill="rgb(200,0,0)">
>  <rect xml:id="shadow" x="7" y="7" width="5" height="5" fill="grey" />
>  <rect xml:id="buttonSurface" fill="inherit" x="5" y="5" width="5" height="5"/>
></g>
></svg>
>
>With uDOM:
>
>function highlightButton(bHighlight) {
>  var nHighlight = (bHighlight ? : 20 : -20);
>  var ele = document.getElementById("buttonSurface");
>  var color = ele.getRGBColorTraitNS(null, "fill");
>  color.red += nHighlight;
>  color.green += nHighlight;
>  color.blue += nHighlight;
>  ele.setRGBColorTraitNS(null, "fill", color);
>}

This is not allowed, the red, green and blue members are readonly and
there is no get/setRGBColorTraitNS method, you would rather

  var color = ele.getRGBColorTrait("fill");
  ele.setRGBColorTrait("fill", document.documentElement.createSVGRGBColor(color.red + nHighlight, color.green + nHighlight, color.blue + nHighlight))

There are other problems like there is no gurantee that your current
fill can be converted to an SVGRGBColor which the script should check
for if it's a general purpose script. Also note that animations might
be applied to the fill property, and the changes you make here would
be reflected in the result of the animation.

>With existing DOM:

Here you should use

  document.documentElement.getComputedStyle(ele,
    '').getPropertyCSSValue('fill')

which would return a RGBColor which is similar to the SVGRGBColor,
but you'd probably have to do the stringification of the result
yourself and use setAttributeNS to update the tree.
-- 
Björn Höhrmann · mailto:bjoern@hoehrmann.de · http://bjoern.hoehrmann.de
Weinh. Str. 22 · Telefon: +49(0)621/4309674 · http://www.bjoernsworld.de
68309 Mannheim · PGP Pub. KeyID: 0xA4357E78 · http://www.websitedev.de/ 

Received on Tuesday, 3 January 2006 18:44:34 UTC