- From: Erik Dahlstrom <ed@opera.com>
- Date: Thu, 15 Apr 2010 17:10:17 +0200
- To: "Patrick Dengler" <patd@microsoft.com>, www-svg <www-svg@w3.org>
On Thu, 15 Apr 2010 16:51:10 +0200, Patrick Dengler <patd@microsoft.com> wrote: > Test case for xlink:href; note the different behaviors across browsers > > > <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" > "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> > <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> > <head> > <meta http-equiv="X-UA-Compatible" content="IE=9"/> > > <script type="text/javascript"> > <![CDATA[ > function testUpdatesetAttrib() > { > var err = document.getElementById("err"); > err.setAttribute("xlink:href", "ie7_logo.png" ); > } > function testUpdatesetAttribNS() > { > var err = document.getElementById("err"); > err.setAttributeNS("xlink","href", "ie7_logo.png" ); > } > > ]]> > </script> > </head> > <body> > <svg xmlns="http://www.w3.org/2000/svg" > xmlns:xlink="http://www.w3.org/1999/xlink" class="container" width="800" > height="800" > > <image xlink:href="ie7_logo2.png" x="200" y="50" width="400" > height="400" id="err" /> > <image xlink:href="ie7_logo.png" x="600" y="50" width="400" > height="400" id="err" /> > </svg> > <input type="button" onclick="testUpdatesetAttrib()" value="Use > settAttribute()" /> > <input type="button" onclick="testUpdatesetAttrib()" value="Use > settAttributeNS()" /> > </body> > </html> Two points: - The second button should call testUpdatesetAttribNS. - The setAttributeNS call should pass a proper namespace URI as the first parameter, "http://www.w3.org/1999/xlink" The proper behaviour in the setAttribute case is undefined according to DOM 3 Core, for the setAttributeNS("xlink","href", "ie7_logo.png") case that doesn't set the attribute in the correct namespace, so shouldn't change the image (since SVG uses the xlink:href attribute for the image data). If the proper namespace was passed the image should be updated correctly. Cheers /Erik -- Erik Dahlstrom, Core Technology Developer, Opera Software Co-Chair, W3C SVG Working Group Personal blog: http://my.opera.com/macdev_ed
Received on Thursday, 15 April 2010 15:11:01 UTC