Permalink
Show file tree
Hide file tree
3 comments
on commit
sign in to comment.
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Switched title attribute to getAttributeNode for IE6/7. Fixes #9329.
- Loading branch information
Showing
2 changed files
with
7 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7d3ba9f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@timmywil
I'm not sure, but I don't think, that this is right. There are 3 things to consider:
Here two examples:
To fix this issue, I had to override jQuery's attr method. See here.
A code which should work more generic and less error prone, should generally check wether the attribute is also a property (IE6/7 mixes this) and then use the 'specified' property instead of the nodeValue property to decide wether the nodeValue or undefined is returned:
//only for ie6/7
var val;
if( !jQuery.support.getSetAttribute && name in elem ){
val = elem.getAttributeNode( name );
val = (val || {}).specified ? val.nodeValue : undefined;
} else {
val = elem.getAttribute( name );
}
return val;
The attr-basher is back again :-).
7d3ba9f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately, using specified was tried first but is not always correct so empty string is the best way I've found to make it consistent. This only pertains to title, name, and attributes on a form which do not have a value or are set to empty string as you've noticed (keep in mind empty string isn't really a valid value for id, title, or name but I understand the argument for consistency). Using specified would still return undefined in many cases, but the formHook opts for always giving the value if it is not empty string instead of sometimes missing out on the value if it's been specified but IE doesn't realize it. I've run into that many times. In the case of your plugin, I suggest adding a custom attrHook for novalidate and formnovalidate to take care of both, but I think we need another solution besides using specified, or perhaps a combination of solutions, but these really are all edge cases.
7d3ba9f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, in case of title, the empty string is a not only valid, it is often used. For example, to override the alt-attribute behavior on img-element in IE6 and IE7. Mozilla also documents, that setting the title attribute to an empty string is the only way to remove the error-tooltip behavior on form elements, which are invalid.
Have you tested getAttribute(name, 0-5)? (I don't think that it works always, but maybee in those cases, where specified do not work. Often this does return really strange values).