Bug Tracker

Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#6884 closed bug (duplicate)

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.

Change History (3)

comment:1 Changed 9 years ago by SlexAxton

Component: unfiledattributes
Milestone: 1.4.31.5
Priority: low
Status: newopen

comment:2 Changed 9 years ago by snover

Resolution: duplicate
Status: openclosed

comment:3 Changed 9 years ago by snover

Duplicate of #3116.

Note: See TracTickets for help on using tickets.