kimoa / svg-edit

Automatically exported from code.google.com/p/svg-edit
MIT License
3 stars 0 forks source link

Order of attributes changes constantly #814

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. load <svg width="640" height="480" xmlns="http://www.w3.org/2000/svg">
 <!-- Created with SVG-edit - http://svg-edit.googlecode.com/ -->
 <g>
  <title>Layer 1</title>
  <path fill="#ff7f00" stroke="#000000" stroke-width="5" d="m167.89964,286.76239l0,-153.56003l0,0" id="svg_2"/>
 </g>
</svg> into the source editor and save changes
2. the first attribute of the path will be the id
3. save changes again
4. the first attribute is again fill

What is the expected output? What do you see instead?
I expect a prefered order of attributes. This is necessary for me to check on 
the server side if there really was a change to the source.

In what browser did you experience this problem? (ALL, Firefox, Opera, etc)
Chrome

In what version of SVG-edit does the problem occur? (Latest trunk, 2.5.1,
etc)
latest

Original issue reported on code.google.com by VSa...@gmail.com on 5 Apr 2011 at 8:38

GoogleCodeExporter commented 9 years ago
Attributes in an XML document are, by definition, unordered.

If you want to determine whether an XML document has changed, doing a bit-wise 
comparison, of the "old" and "new" documents, is probably not the way you want 
to do it.

Instead, compare the XOM trees produced by parsing the two documents. There are 
*lots* of utilities for doing that, in every language under the sun. Here, for 
instance, is one in Ruby:

    http://kallokain.blogspot.com/2006/01/testunitxml-quick-start-tutorial.html

Original comment by jacques....@gmail.com on 14 Apr 2011 at 4:24

GoogleCodeExporter commented 9 years ago
I have noticed this too, in Chrome 19.0.1084.56 m, using SVG-edit v2.6-alpha 
(latest trunk).

I understand that the attribute order itself doesn't matter, but consistency 
does, for the user's sake. The attribute order in the <path> tags alternates 
between id, d, fill and fill, d, id every time I edit, save, and reopen the 
source code. This is annoying and distracting and makes it difficult to see 
which path is which at a glance.

Original comment by iano.not...@gmail.com on 13 Jun 2012 at 8:58

GoogleCodeExporter commented 9 years ago
It is actually a complete swap-ends of the whole attribute list.

Original comment by StephenF...@gmail.com on 20 Apr 2013 at 9:50

GoogleCodeExporter commented 9 years ago
In my workflow I need to manually check SVG content and attribute reversal is 
really annoying. Is there a quick way to implement alphabet sorting for 
attribute order?

Original comment by josipmis...@gmail.com on 8 Sep 2013 at 8:55

GoogleCodeExporter commented 9 years ago
This should be a very easy fix. Either read the attributes in the opposite 
order, or write them out in the opposite order. I'd suggest fixing it in the 
output, since that needs other work, such as not outputting so many 
useless="null" attributes. 
Actually, I looked into this with the debugger and it really does just output 
the attributes backwards.

in svgcanvas.js:~4165, the code
                i = attrs.length;
                ...
                while (i--) {...}
should be
                                ...
                                for (var i = 0, l = attrs.length; i < l; i++) {...}

Original comment by isaiahod...@gmail.com on 2 Apr 2014 at 6:33