W3C home > Mailing lists > Public > www-svg@w3.org > February 2010

Questions on SVG DOM Change Propogation

From: Patrick Dengler <patd@microsoft.com>
Date: Tue, 9 Feb 2010 18:22:08 +0000
To: "www-svg@w3.org" <www-svg@w3.org>
Message-ID: <4A2DB3AE4504E944AF122BBFBA7FBA1F42D82F2C@TK5EX14MBXC114.redmond.corp.microsoft.com>
Hi folks,

We are seeing some differing behaviors across implementations on DOM Propagation.  We'd like to nail the appropriate behaviors.  (forgive the length again)


Scenario 1: SVG DOM Type set on a value.
    function singleset(evt) {
        var root = evt.target.ownerDocument.rootElement;
        var marker0 = root.firstChild.nextSibling.firstChild.nextSibling;
        var angle0 = root.createSVGAngle();
        marker0.setOrientToAngle(angle0);
        alert(0);
        angle0.newValueSpecifiedUnits(SVGAngle.SVG_ANGLETYPE_DEG, 30);
    }

Safari: marker0 angle is updated.
Firefox: marker0 angle is not updated.
Opera: marker0 angle is not updated.


Scenario 2: SVG DOM Type set on multiple values.
    function multiset(evt) {
        var root = evt.target.ownerDocument.rootElement;
        
        var marker0 = root.firstChild.nextSibling.firstChild.nextSibling;
        var marker1 = marker0.nextSibling.nextSibling;

        var angle0 = root.createSVGAngle();

        marker0.setOrientToAngle(angle0);
        marker1.setOrientToAngle(angle0);

        alert(0);

        angle0.newValueSpecifiedUnits(SVGAngle.SVG_ANGLETYPE_DEG, 30);
    }
Safari: marker0 and marker1 angles are updated.
Firefox: No angles are updated.
Opera: No angles are updated.

Scenario 3: Multiple SVG DOM Types set on a single value
    function multiangle(evt) {
        var root = evt.target.ownerDocument.rootElement;
        var marker0 = root.firstChild.nextSibling.firstChild.nextSibling;
        var angle0 = root.createSVGAngle();
        var angle1 = root.createSVGAngle();
        angle1.newValueSpecifiedUnits(SVGAngle.SVG_ANGLETYPE_DEG, 30);
        alert(0);
        marker0.setOrientToAngle(angle0);
        alert(1);
        marker1.setOrientToAngle(angle1);
        alert(2);
        angle0.newValueSpecifiedUnits(SVGAngle.SVG_ANGLETYPE_DEG, 60);
        alert(2);
        angle1.value = 0.0        
    }
Safari: Only changes on the last set angle.
Firefox: Does not change on attribute modification.
Opera: Does not change on attribute modification.

Essentially for Scenarios 1 - 3
Safari holds a reference to the passed angle. When the angle attributes change, the object that owns the angle updates. Opera and Firefox do not copy the reference and do not get linked to the angle.

Scenario 4: Modifying the baseVal of a target's animation value.
    function modifyGetter(evt) {
        var root = evt.target.ownerDocument.rootElement;
        var marker0 = root.firstChild.nextSibling.firstChild.nextSibling;
        var angle0 = marker0.orientAngle;
        angle0.newValueSpecifiedUnits(SVGAngle.SVG_ANGLETYPE_DEG, -30);
    }
Safari: Does not handle negative angles, but changes otherwise.
Firefox: Changes on attribute modification.
Opera: Changes on attribute modification.

Scenario 5: Modifying an element of a list retrieved from a target's animated value.
    function modifyElement(evt) {
        var root = evt.target.ownerDocument.rootElement;
        var g0 = root.firstChild.nextSibling.nextSibling.nextSibling;
        var g1 = g0.firstChild.nextSibling.nextSibling.nextSibling;
        var text0 = g1.firstChild.nextSibling; // SVGTextElement
        var xList0 = text0.x.baseVal;
        var xLength = xList0.getItem(0);
        alert(0);
        xLength.value = 2*xLength.value + 10
    }
Safari: Does not update the text position.
Firefox: Does not draw text.
Opera: Changes text position.

Scenario 6: Setting the element of a list retrieved from a target's animated value.
    function replaceElement(evt) {
        var root = evt.target.ownerDocument.rootElement;
        var g0 = root.firstChild.nextSibling.nextSibling.nextSibling;
        var g1 = g0.firstChild.nextSibling.nextSibling.nextSibling;
        var text0 = g1.firstChild.nextSibling; // SVGTextElement
        var xList0 = text0.x.baseVal;
        
        var oldLength = xList0.getItem(0);
        var newLength = root.createSVGLength();
        newLength.newValueSpecifiedUnits(
oldLength.unitType, 
2*oldLength.value + 10);
        
        alert(0);
        xList0.replaceItem(newLength, 0);
    }
Safari: Updates the text position.
Firefox: Still not drawing. Also, replaceItem throws an exception.
Opera: Updates the text position.


Scenario 7: Setting the baseVal of a target's animation value.
    function setTarget(evt) {
        var root = evt.target.ownerDocument.rootElement;
        var a = root.firstChild.nextSibling;
        var aniStr = a.target;
        alert(aniStr.baseVal);
        aniStr.baseVal = "_foo";
        alert(a.target.baseVal);
    }
Safari: Updates the link target.
Firefox: Updates the link target (and open the new target in a tab instead of a window).
Opera: Does not support links.

Clarifications are appreciated!

Patrick Dengler
Received on Tuesday, 9 February 2010 18:25:11 GMT

This archive was generated by hypermail 2.3.1 : Friday, 8 March 2013 15:54:44 GMT