Ticket #11166 (closed bug: wontfix)
attr("viewBox") broken by case folding
| Reported by: | norman.pellet@… | Owned by: | timmywil |
|---|---|---|---|
| Priority: | low | Milestone: | None |
| Component: | attributes | Version: | 1.7.1 |
| Keywords: | Cc: | ||
| Blocking: | Blocked by: |
Description
Hi !
May I let you take a look at this fiddle ?
I think there is an issue while retrieving the viewBox attribute with inline svg. Do I make any sense ?
Thanks !
Change History
comment:2 Changed 17 months ago by timmywil
- Owner set to timmywil
- Priority changed from undecided to low
- Status changed from new to assigned
- Component changed from unfiled to attributes
Confirmed. http://jsfiddle.net/timmywil/HTZ9n/7/show/
The viewBox attribute should stay camelCase. SVG may be the only exception where attribute names are not lowercase. http://www.w3.org/TR/SVG/coords.html#ViewBoxAttribute
comment:3 Changed 14 months ago by anonymous
Is this perhaps down to the issue described here? http://api.jquery.com/prop/ The element seems retrievable with .prop, but not with .attr.
comment:4 Changed 11 months ago by dmethvin
- Summary changed from attr("viewBox") doesn't work to attr("viewBox") broken by case folding
It seems like the DOM attribute methods are case insensitive on sane browsers, so perhaps we can just skip the .toLowerCase() part? In a quick check to .attr() I just moved the lowercase to getting the attrHook only and got a full pass including IE7 and IE8. I wasn't able to get a full test in IE6 due to some BrowserStack issues.
In environments where there is case sensitivity (including IE7 HTML) I don't think there is any way to hide that, so documenting that the case must match seems fine to me.
--- a/src/attributes.js
+++ b/src/attributes.js
@@ -305,8 +305,7 @@ jQuery.extend({
// All attributes are lowercase
// Grab necessary hook if one is defined
if ( notxml ) {
- name = name.toLowerCase();
- hooks = jQuery.attrHooks[ name ] || ( rboolean.test( name ) ? boolHook : nodeHook );
+ hooks = jQuery.attrHooks[ name.toLowerCase() ] || ( rboolean.test( name ) ? boolHook : nodeHook );
}
if ( value !== undefined ) {
comment:5 Changed 10 months ago by timmywil
Attributes are not case sensitive in IE when using getAttributeNode, which we use for all html attributes in IE. viewBox is technically an svg attribute that should be rendered with xhtml or xml, which is why it is case-sensitive. I think the best solution would be to have a test for svg, if possible.
comment:6 Changed 8 months ago by mikesherov
- Status changed from assigned to closed
- Resolution set to wontfix
Unfortunately, we don't support SVG, and even though this worked in the past, it's not something we're supporting so we're not going to fix it for now. If we decide to support SVG in the future, we'll reopen and address this issue.
Thanks!
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

A few more things:
Tested on Firefox 9.0.1, Chrome 17.0.963.33 beta, Safari 5.1.1
worked with jQuery 1.6.4