prototypejs / prototype

Prototype JavaScript framework
http://prototypejs.org/
Other
3.54k stars 640 forks source link

getOpacity malfunctions with IE 9 #175

Open jwestbrook opened 10 years ago

jwestbrook commented 10 years ago

previous lighthouse ticket #1671 by Matthew Schultz


getOpacity malfunctions with IE 9 by not setting it properly because it is retrieved as a string. The reason for this is getStyle is overwritten with this:

if ('styleFloat' in DIV.style) { methods.getStyle = getStyle_IE; methods.setOpacity = setOpacity_IE; methods.getOpacity = getOpacity_IE; }

Here's the trace of what happens to trigger this bug:

Element.getOpacity(element); Element.getStyle(element, 'opacity'); <- overwritten Element.getStyle_IE(element, 'opacity'); return $value; <- getOpacity_IE is not called because standard opacity is supported I have enclosed a patch which will fix this problem. This ensures that when getOpacity_IE gets called and the standard opacity call is supported, it will actually call the standard call instead of using the overwritten one.

diff --git a/src/prototype/dom/dom.js b/src/prototype/dom/dom.js
index f14639b..b456875 100644
--- a/src/prototype/dom/dom.js
+++ b/src/prototype/dom/dom.js
@@ -2847,6 +2847,10 @@
    *  
   **/
   function getStyle(element, style) {
+    return getDomStyle(element, style);
+  }
+
+  function getDomStyle(element, style) {
     element = $(element);
     style = normalizeStyleName(style);

@@ -2989,7 +2993,7 @@
    *  Returns the opacity of the element.
   **/
   function getOpacity(element) {
-    return Element.getStyle(element, 'opacity');
+    return getDomStyle(element, 'opacity');
   }

   function getOpacity_IE(element) {
jwestbrook commented 10 years ago

Victor January 24th, 2013 @ 08:20 PM

I've made pull request for opacity in IE9 4 months ago: https://github.com/sstephenson/prototype/pull/73

savetheclocktower commented 9 years ago

I need to investigate whether this is still happening.