Search and Top Navigation
#5694 closed bug (fixed)
Opened June 06, 2010 04:50PM UTC
Closed June 28, 2010 02:37AM UTC
Last modified November 19, 2010 06:25PM UTC
Invalid reference in UI Resizable hack for Opera
Reported by: | jquery-dev | Owned by: | |
---|---|---|---|
Priority: | critical | Milestone: | 1.8.3 |
Component: | ui.resizable | Version: | 1.8.1 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
There is an error in the resizable.alsoResize() method, in a section that is specific to Opera...
$.ui.plugin.add("resizable", "alsoResize", { ... stop: function(event, ui){ var self = $(this).data("resizable"); //Opera fixing relative position if (self._revertToRelativePosition && $.browser.opera) { self._revertToRelativePosition = false; el.css({ position: 'relative' }); } $(this).removeData("resizable-alsoresize-start"); }
The reference 'el' does not exist, so Opera bombs out with...
Uncaught exception: ReferenceError: Undefined variable: el el.css({ position: 'relative' });
It ''seems'' this is because the code in this method was copied from the method above it, where el ''is'' defined within a loop:
resize: function(event, ui){ ... _alsoResize = function(exp, c) { $(exp).each(function() { var el = $(this), ...; ... //Opera fixing relative position if (/relative/.test(el.css('position')) && $.browser.opera) { self._revertToRelativePosition = true; el.css({ position: 'absolute', top: 'auto', left: 'auto' }); } el.css(style); });
In the stop() method, el cannot be assigned to $(this) because that is the outer dialog element and it is the dialog content-element that needs to be reset. So this hack works specifically for the dialog widget...
var el = $(this).children(".ui-dialog-content");
But obviously this needs to be generic - targeting the same element(s) targeted in the resize method, because that is what it is supposed to 'undo'.
This error also existed in version 1.7.2. It has probably been missed for so long because it occurs only under these conditions:.
- $.browser.opera = true, and
- self._revertToRelativePosition = true
The revertToRelativePosition flag is set when the alsoResize target element has position=relative, which Opera ''temporarily'' changes to absolute.
Having a resizable element with position:relative is not unusual, and since resizable is used by many other widgets (I discovered it in Dialog), this represents a serious bug in Opera.
Attachments (0)
Change History (8)
Changed June 08, 2010 04:00PM UTC by comment:1
Changed June 09, 2010 09:54PM UTC by comment:2
FYI, I have now committed this patch to Github:
http://github.com/ALLPRO/jquery-ui/commit/8915fcf35a0643bff9ae2a1aa84d01fb3502001a
Changed June 10, 2010 01:37AM UTC by comment:3
milestone: | TBD → 1.9 |
---|---|
resolution: | → fixed |
status: | new → closed |
Fixed in a78d5ee.
Changed June 25, 2010 03:26PM UTC by comment:4
resolution: | fixed |
---|---|
status: | closed → reopened |
Again, code (to stop function) was copied without checking. Opera returns an error in line:
if (typeof(o.alsoResize) == 'object' && !o.alsoResize.nodeType)
Of course because there is no "o" variable. That "stop" function misses "var o = self.options;"
Changed June 25, 2010 03:27PM UTC by comment:5
Changed June 28, 2010 02:37AM UTC by comment:6
resolution: | → fixed |
---|---|
status: | reopened → closed |
Fixed in 7d24c1a. Thanks eXtreme.
Changed August 04, 2010 01:18AM UTC by comment:7
milestone: | 1.9 → 1.8.3 |
---|
I resolved the bug above. In addition to fixing this ''and'' the other bug I reported (http://dev.jqueryui.com/ticket/5695), I also found the Opera hack logic incomplete. The previous code would 'reset' an element's position from absolute to relative even if it was ''originally'' absolute. Now each element's original position is save in start().
This revised code is a complete fix for all issues. I may also submit this directly to the repository, but am also posting it here to complete this ticket...