Skip to main content

Bug Tracker

Side navigation

#6884 closed bug (duplicate)

Opened August 07, 2010 08:17AM UTC

Closed November 21, 2010 04:43AM UTC

Last modified November 21, 2010 04:43AM UTC

XML introspection confused when SVG embedded in <script> tag

Reported by: cefn Owned by:
Priority: low Milestone: 1.5
Component: attributes Version: 1.4.2
Keywords: xml svg attr setAttribute Cc:
Blocked by: Blocking:
Description

Using attr(map) to set attributes on embedded SVG elements triggers an error in JQuery, whilst directly setting the attributes works fine.

I'm following instructions in the SVGWeb tutorial to embed SVG in the page, using a script tag with type="image/svg+xml"

http://codinginparadise.org/projects/svgweb/docs/QuickStart.html

I understand this is supported by many browsers.

JQuery introspects elements to judge whether or not it should use setAttribute(name,value) for XML documents or elem[name]=value for DOM0 documents, but the logic doesn't detect that this SVG element actually requires the setAttribute(...) style invocation suitable for XML.

The logic in 1.4.2 looks like this...

var notxml = elem.nodeType !== 1 || !jQuery.isXMLDoc( elem )

...and attr() falls through to Line 1493 calling...

elem[ name ] = value;

...triggering the error "setting a property that has only a getter"

The example code at http://pastebin.com/U1kyLxVE contains an attr() call which triggers the error, and contains a commented version of equivalent setAttribute calls which do not trigger the error.

The logic of 'notxml' should be modified to capture such cases and make attr() work. For example, the namespaceURI of this element is http://www.w3.org/2000/svg so it is indeed possible to detect the case.

Attachments (0)
Change History (3)

Changed October 27, 2010 06:02PM UTC by SlexAxton comment:1

component: unfiledattributes
milestone: 1.4.31.5
priority: → low
status: newopen

Changed November 21, 2010 04:43AM UTC by snover comment:2

resolution: → duplicate
status: openclosed

Changed November 21, 2010 04:43AM UTC by snover comment:3

Duplicate of #3116.