From c27f2de3730bbca871315690e6f522e6f1adbb9f Mon Sep 17 00:00:00 2001 From: Sam Stephenson Date: Tue, 14 Aug 2007 04:14:22 +0000 Subject: [PATCH] prototype: Fix failing dom.html and selector.html tests in IE. --- CHANGELOG | 2 ++ src/dom.js | 45 ++++++++++++++++++++++----------------------- 2 files changed, 24 insertions(+), 23 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index f628d2a..dd80ab9 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* Fix failing dom.html and selector.html tests in IE. [Tobie Langel, Andrew Dupont] + * Make sure the WebKit redefinition of Element#cumulativeOffset uses Element._returnOffset. Closes #9245. [mdaines] * Make sure Element#observe and Element#stopObserving are always chainable. [sam] diff --git a/src/dom.js b/src/dom.js index 9748c76..b335a8f 100644 --- a/src/dom.js +++ b/src/dom.js @@ -271,7 +271,11 @@ Element.Methods = { var t = Element._attributeTranslations.read; if (t.values[name]) return t.values[name](element, name); if (t.names[name]) name = t.names[name]; - } + if (name.include(':')) { + return (!element.attributes || !element.attributes[name]) ? null : + element.attributes[name].value; + } + } return element.getAttribute(name); }, @@ -735,15 +739,15 @@ if (Prototype.Browser.Opera) { } else if (Prototype.Browser.IE) { - ['positionedOffset','getOffsetParent'].each(function(method){ + $w('positionedOffset getOffsetParent viewportOffset').each(function(method) { Element.Methods[method] = Element.Methods[method].wrap( - function(proceed, element){ + function(proceed, element) { element = $(element); - if (element.getStyle('position') == 'static') return proceed(element); - var position = element.getStyle(position); - element.setStyle({position: 'relative'}); + var position = element.getStyle('position'); + if (position != 'static') return proceed(element); + element.setStyle({ position: 'relative' }); var value = proceed(element); - element.setStyle({position: position}); + element.setStyle({ position: position }); return value; } ); @@ -813,19 +817,7 @@ else if (Prototype.Browser.IE) { }; Element._attributeTranslations.write = { - names: Object.extend({ - colspan: 'colSpan', - rowspan: 'rowSpan', - valign: 'vAlign', - datetime: 'dateTime', - accesskey: 'accessKey', - tabindex: 'tabIndex', - enctype: 'encType', - maxlength: 'maxLength', - readonly: 'readOnly', - longdesc: 'longDesc' - }, Element._attributeTranslations.read.names), - + names: Object.clone(Element._attributeTranslations.read.names), values: { checked: function(element, value) { element.checked = !!value; @@ -837,6 +829,14 @@ else if (Prototype.Browser.IE) { } }; + Element._attributeTranslations.has = {}; + + $w('colSpan rowSpan vAlign dateTime accessKey tabIndex ' + + 'encType maxLength readOnly longDesc').each(function(attr) { + Element._attributeTranslations.write.names[attr.toLowerCase()] = attr; + Element._attributeTranslations.has[attr.toLowerCase()] = attr; + }); + (function(v) { Object.extend(v, { href: v._getAttr, @@ -1034,9 +1034,8 @@ Element._insertionTranslations = { Element.Methods.Simulated = { hasAttribute: function(element, attribute) { - var t = Element._attributeTranslations.read, node; - attribute = t.names[attribute] || attribute; - node = $(element).getAttributeNode(attribute); + attribute = Element._attributeTranslations.has[attribute] || attribute; + var node = $(element).getAttributeNode(attribute); return node && node.specified; } };