... If i set in jQuery update 1.8 version something happens to body style: padding-top: 65px that is default in there where toolbar drawer exist. So when this happens there is a gap between toolbar and rest of site. When i select 1.5 or 1.7 everything is OK as usual.
| Comment | File | Size | Author |
|---|---|---|---|
| #11 | fix_jquery_outer_functions-1951588-11.patch | 1.99 KB | jay.dansand |
| #4 | overlay-parent.js_.patch | 260 bytes | studiotwelve |
Comments
Comment #1
ericduran commentedYes, I've noticed this too.
Patches welcome :)
Comment #2
joos commentedThis i a bug in jQuery (http://bugs.jquery.com/ticket/12159)
Line #876 in "modules/overlay/overlay-parent.js" returns an object.
JQ1.8
lastDisplaced.offset().top+lastDisplaced.outerHeight()
= "0[object Object]"
JQ1.7
lastDisplaced.offset().top+lastDisplaced.outerHeight()
= 65
Comment #3
joos commented//are monkey patches ok?
if(jQuery && jQuery.fn.jquery == "1.8.2") {
jQuery.fn._outerHeight = jQuery.fn.outerHeight;
jQuery.fn.outerHeight = function() { return jQuery(this)._outerHeight(false); }
}
Comment #4
studiotwelve commentedMade a patch...
Comment #5
jay.dansand commentedSince jQuery Update is the project creating the problem (by allowing jQuery 1.8+), shouldn't it solve the problem as well (instead of patching Drupal core JavaScript files)?
The bug is in jQuery's
.outerWidthand.outerHeightfunctions in 1.8+, which Drupal Core uses in a few places. Any solution needs to involve fixing these functions, not rewriting core to avoid using them.The bug in jQuery is that
.outerWidth([includeMargin])and.outerHeight([includeMargin])(overlay-parent.js uses both of these!) are both broken in jQuery 1.8+, and return a jQuery object instead of a number when called without theincludeMarginparameter.This is a bug because the jQuery docs say that either no parameter or
falseshould work the same. The easy, universal fix is to overrideouterWidthandouterHeightto default toincludeMargin = false.Here's an example fix. All it does is call the real jQuery functions with
falseinstead ofundefinedwhen theincludeMarginparameter is missing.I've hand-minified a version of that function, which I'm using in my own template's .js to temporarily solve the problem:
Comment #6
treksler commentedthe bug in jquery has been marked invalid BTW
http://bugs.jquery.com/ticket/12293
Comment #7
jay.dansand commentedTicket http://bugs.jquery.com/ticket/12293 is just one of literally dozens of tickets covering this issue, so it's hard to say what the true status is. Regardless, it's undeniably a bug:
includeMarginparameter is optional..outerWidth()and.outerHeight()without any parameter.null, (never an object):After 1.8, it sometimes returns an object.
It used to work, the specs say it should work, but it no longer works. That's pretty clearly a bug. My proposed fix is simple and should be non-disruptive: all we do is supply
falseif the optionalincludeMarginparameter is missing. Then jQuery 1.8+ is happy, and all existing code will continue to work as the jQuery docs say it should.Comment #8
nod_It's totally fair, it's JS anything goes. We sure like bikesheading in core but we don't bite #2018791-6: states.js is not compatible with jquery +1.6.1 because it use $.attr in the wrong way.
< troll>null is an object< /troll>
More generally, feel free to open core bugs against D7 if the change isn't too drastic and it makes it easier on jquery_update.
Comment #9
jay.dansand commentedLet me be more specific:
Not a jQuery object, which is what it returns in jQuery 1.8+.
I would open a core bug, except that the changes in jQuery 1.8 will likely impact contrib as well, so the solution seems most fitting to apply universally: where jQuery 1.8 is used (which only happens with jQuery Update), we solve the problem it introduces.
My rationale is based on two possible solutions:
falseas the optional (except effectively it's no longer optional in jQuery 1.8+, even though the docs still say it is) 2nd parameter toouterWidth()andouterHeight(), and hope that fixes everything. This is a bad idea, because who knows what other contrib modules may use those functions, based on any version of jQuery prior to 1.8. That means running jQuery Update + contrib will open up possible errors down the road. We would then have to file issues and fix every one of those otherwise-valid Drupal 7.x contrib modules, just because jQuery 1.8+ has a bug and jQuery Update is enabling jQuery 1.8+. This seems the wrong way. Fixing it in core will not fix contrib.outerWidth()andouterHeight()functionality, and all existing contrib and core JS will run without any problem. This is totally backwards, forwards, all directions compatible, non-side-effecting, safe and easy. This seems the right way. The very tiny JS in #5 does this.Comment #10
nod_In that case sure, fixing core doesn't sound like the right solution. But in case people had the wrong idea, it's not impossible to patch core for the right issue.
Lots of people here I haven't seen in the core queue. Just doing some light poking/recruiting, don't mind me :D
Comment #11
jay.dansand commentedWe probably all think Drupal Core is scary :)
Here's a patch that integrates the JS from #5 and automatically inserts it if the requested jQuery version is 1.8+.
I noticed when rolling the patch against the latest 7.x-2.x-dev that there's a new replace/misc/1.9/overlay-parent.js that jQuery Update is overriding core with, but it looks like (from overlay-parent.diff.js) it isn't doing anything to solve the outerWidth/outerHeight problem, so I don't think it conflicts with this fix.
Comment #12
hefox commentedThis isn't needed with -dev as far as I can tell, which fixes the incomportable versions of jquery/jquery ui http://bugs.jquery.com/ticket/12491#comment:2
Comment #13
jay.dansand commentedThat ticket seems to be about jQuery UI solving the problem (by changing how they use the outerWidth/outerHeight functions), not the jQuery bug getting fixed. So, the problem still remains for core/contrib scripts written against any version of jQuery < 1.8 (unless I'm reading something incorrectly, which is always a possibility!).
Comment #14
hefox commentedUsing jquery update stable, $().outerWidth returned an object; using -dev outerWidth returned the width
Comment #15
markhalliwellThis sounds like a jQuery version/API deprecation issue and can resolved in the 7.x-3.x branch by either: