Use feature testing in Element#readAttribute
when taking care of Opera's getAttribute('title')
quirk
This commit is contained in:
parent
d4c182c03d
commit
3e3b470009
@ -1,3 +1,5 @@
|
||||
* Use feature testing in `Element#readAttribute` when taking care of Opera's `getAttribute('title')` quirk. (kangax)
|
||||
|
||||
* Use `Prototype.emptyFunction` consistently throughout unit tests. [#253 state:resolved] (Michael M Slusarz, John David Dalton, kangax)
|
||||
|
||||
* deprecation extension: mark Array#reduce() as removed. [#569 state:resolved] (Tobie Langel)
|
||||
|
@ -609,6 +609,15 @@ Element.Methods = {
|
||||
return isBuggy;
|
||||
})();
|
||||
|
||||
// Opera 9.25 returns `null` instead of "" for getAttribute('title')
|
||||
// when `title` attribute is not present
|
||||
var GET_ATTRIBUTE_TITLE_RETURNS_NULL = (function(){
|
||||
var el = document.createElement('div');
|
||||
var isBuggy = (el.getAttribute('title') === null);
|
||||
el = null;
|
||||
return isBuggy;
|
||||
})();
|
||||
|
||||
return function(element, name) {
|
||||
element = $(element);
|
||||
// check boolean first, to get out of expression faster
|
||||
@ -617,6 +626,9 @@ Element.Methods = {
|
||||
element.tagName.toUpperCase() == 'IFRAME') {
|
||||
return element.getAttribute('type');
|
||||
}
|
||||
if (GET_ATTRIBUTE_TITLE_RETURNS_NULL && name === 'title') {
|
||||
return element.title;
|
||||
}
|
||||
if (Prototype.Browser.IE) {
|
||||
var t = Element._attributeTranslations.read;
|
||||
if (t.values[name]) return t.values[name](element, name);
|
||||
@ -1230,13 +1242,6 @@ if (Prototype.Browser.Opera) {
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
Element.Methods.readAttribute = Element.Methods.readAttribute.wrap(
|
||||
function(proceed, element, attribute) {
|
||||
if (attribute === 'title') return element.title;
|
||||
return proceed(element, attribute);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
else if (Prototype.Browser.IE) {
|
||||
|
Loading…
Reference in New Issue
Block a user