Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Slight bug with SVG XML getting added whitespace

3 views
Skip to first unread message

Brett Zamir

unread,
May 12, 2009, 6:41:06 PM5/12/09
to
Hi,

In doing some testing for JavaScript SAX2 parser
(http://code.google.com/p/jssaxparser/ ), I discovered that in one of
our tests (which checked for identity among attributes within the
built-in parser and our own which started from
document.implementation.createDocument), when using SVG, certain
attributes were altered by Firefox. While FF 3.5 avoids the issue of
"scale(4)" turning into "scale(4, 4)", the built-in DOMParser() still
auto-changes the whitespace.

// No space
var text = '<svg xmlns="http://www.w3.org/2000/svg">'+
'<g transform="translate(20,20) scale(4)"></g></svg>';

// The attribute value now has an extra space within the translate()
function
var t = new DOMParser().parseFromString(text,"text/xml");
alert(t.getElementById('a').getAttribute('transform'));

// Here it is again showing the whole document
alert(new XMLSerializer().serializeToString(new
DOMParser().parseFromString(text,"text/xml"))); <svg
xmlns="http://www.w3.org/2000/svg"><g transform="translate(20, 20)
scale(4)"/></svg>

If you change the SVG namespace (to make this some other XML), the
attribute no longer adds a space.

So, while this issue doesn't apparently affect functionality, it still
causes problems for those which reflect on XML...

File a bug?

Brett

Boris Zbarsky

unread,
May 12, 2009, 8:41:42 PM5/12/09
to
Brett Zamir wrote:
> when using SVG, certain
> attributes were altered by Firefox.

I believe SVG allows normalizing attribute values, yes...

-Boris

0 new messages