On Dec 11, 11:10 am, John Resig <jere...@gmail.com> wrote: > > 1) It still confuses properties and attributes, which is its biggest > > problem. Behavior is unpredictable. This is bad. > Do you have any specific examples?
For example: <input type="checkbox" id="x" readonly="readonly"> $('#x').attr('readonly') === true This is a boolean property of the element, not its attribute value. The name attr() implies that it deals with attributes. But the code actually gets/sets properties as the first line of business. I would expect to get back the string "readonly". > > 2) It looks like new code was added to call the jQuery method if the > > requested attribute is in jQuery.fn. But what about attributes like > > "height" or "wrap"? It won't retrieve the attribute value, but > > instead, runs the height() or wrap() methods! > The wrap one was a mistake (the code in 1.4a1 covered too many > methods) it's since been scaled back. In the case of height, for > example, we definitely do want to get the height value as reported by > .height(), especially since it's likely to be more accurate than > trying to get elem.height. But isn't the attr() method supposed to get the height _attribute_ value? If the attribute is set to "5" and I manipulate it via js, I still want to get "5" if I look for the attribute value. Otherwise I would just call height(). So now the attr() method either calls a jQuery method, gets/sets an element's property, or gets/sets an element's attribute. How is a user supposed to know what to expect? What exactly is the attr() method intended to do, if not get/set an element's attributes? Calling attr() becomes a crap-shoot, because you can never be sure what it's going to do inside. > > 3) The list in jQuery.props is still incomplete > Do you have any specific examples? cellPadding, useMap, accessKey, et al. > > 4) The "special" cases list is still incomplete > Do you have any specific examples? How about 'action'? > > 5) It forces values to be strings, so I can't set attributes like attr > > ('onclick',function(){...}) which in theory should work just fine. In > > FF, for example, el.setAttribute('onclick',function(){...}) works as > > expected. > I don't think that's a case that we particularly want to support, > though. In 1.4 you can just do: .attr("click", function(){}) and it > would work (albeit tied into the full event system, which is much > better). But now you have an setAttribute wrapper that causes a script error when passed values that would work just fine with setAttribute(). This seems like a step backwards. > > Referenced is a good, robust review of attribute handling with test > > cases that should probably be in the jQuery test suite: > >http://www.cinsoft.net/attributes.html > I don't see a particular license on those tests - are they available > under an MIT license? You'd have to contact the author, not sure about that. But the cases being tested are certainly something that can be written again on their own. I just saw that you've made some progress on this, which is great. > > Any hopes of fixing it up soon? > Specific filed bugs and test cases would certainly accelerate the process. This is core functionality, and filing/patching bugs on specific problems with individual attributes wouldn't be very helpful. In fact, that's perhaps what lead to the method being in the state it is (with attmpted special cases for tabindex, selected, etc). Instead, I think someone needs to step back and identify _exactly_ what it is that attr () is supposed to do, and then code to that standard. Kind of hard now that you want to maintain backwards-compatibility with this kind of hybrid functionality, though. Throwing in the hidden execution of jquery methods when trying to retrieve attribute values just adds to the confusion even more, and I'm not sure what exactly attr() is trying to accomplish if that is seen as necessary. It's been pointed out that most users don't really need to interact with attributes to begin with. In most cases, they want to get/set properties of objects, not their attributes. A prop() method might be more clear, along with attr() if you really, really need to get/set attributes. Mixing the two (and trying to throw in xml support!) just makes the whole thing kind of a mess. Matt Kruse -- You received this message because you are subscribed to the Google Groups "jQuery Development" group. To post to this group, send email to jquery-...@googlegroups.com. To unsubscribe from this group, send email to jquery-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/jquery-dev?hl=en.