Permalink
Browse files

Build and bump version to 1.3.3

  • Loading branch information...
1 parent 5f90608 commit 7e43e95331ddf6bf7d65a88bc1b9bfbee8492d23 @TrevorBurnham TrevorBurnham committed Jul 14, 2016
Showing with 71 additions and 35 deletions.
  1. +1 −1 bower.json
  2. +1 −1 component.json
  3. +63 −27 dist/js/tether.js
  4. +1 −1 dist/js/tether.min.js
  5. +2 −2 docs/welcome/js/jquery.js
  6. +2 −2 examples/resources/js/jquery.js
  7. +1 −1 package.json
View
@@ -1,6 +1,6 @@
{
"name": "tether",
- "version": "1.3.2",
+ "version": "1.3.3",
"homepage": "http://github.hubspot.com/tether",
"authors": [
"Zack Bloom <zackbloom@gmail.com>",
View
@@ -1,7 +1,7 @@
{
"name": "tether",
"repo": "HubSpot/tether",
- "version": "1.3.2",
+ "version": "1.3.3",
"description": "A client-side library to make absolutely positioned elements attach to elements in the page efficiently.",
"authors": [
"Zack Bloom <zackbloom@gmail.com>",
View
@@ -1,4 +1,4 @@
-/*! tether 1.3.2 */
+/*! tether 1.3.3 */
(function(root, factory) {
if (typeof define === 'function' && define.amd) {
@@ -23,6 +23,32 @@ if (typeof TetherBase === 'undefined') {
var zeroElement = null;
+// Same as native getBoundingClientRect, except it takes into account parent <frame> offsets
+// if the element lies within a nested document (<frame> or <iframe>-like).
+function getActualBoundingClientRect(node) {
+ var boundingRect = node.getBoundingClientRect();
+
+ // The original object returned by getBoundingClientRect is immutable, so we clone it
+ // We can't use extend because the properties are not considered part of the object by hasOwnProperty in IE9
+ var rect = {};
+ for (var k in boundingRect) {
+ rect[k] = boundingRect[k];
+ }
+
+ if (node.ownerDocument !== document) {
+ var _frameElement = node.ownerDocument.defaultView.frameElement;
+ if (_frameElement) {
+ var frameRect = getActualBoundingClientRect(_frameElement);
+ rect.top += frameRect.top;
+ rect.bottom += frameRect.top;
+ rect.left += frameRect.left;
+ rect.right += frameRect.left;
+ }
+ }
+
+ return rect;
+}
+
function getScrollParents(el) {
// In firefox if the el is inside an iframe with display: none; window.getComputedStyle() will return null;
// https://bugzilla.mozilla.org/show_bug.cgi?id=548397
@@ -58,7 +84,13 @@ function getScrollParents(el) {
}
}
- parents.push(document.body);
+ parents.push(el.ownerDocument.body);
+
+ // If the node is within a frame, account for the parent window scroll
+ if (el.ownerDocument !== document) {
+ parents.push(el.ownerDocument.defaultView);
+ }
+
return parents;
}
@@ -92,13 +124,7 @@ var getOrigin = function getOrigin() {
var id = node.getAttribute('data-tether-id');
if (typeof zeroPosCache[id] === 'undefined') {
- zeroPosCache[id] = {};
-
- var rect = node.getBoundingClientRect();
- for (var k in rect) {
- // Can't use extend, as on IE9, elements don't resolve to be hasOwnProperty
- zeroPosCache[id][k] = rect[k];
- }
+ zeroPosCache[id] = getActualBoundingClientRect(node);
// Clear the cache when this position call is done
defer(function () {
@@ -127,13 +153,7 @@ function getBounds(el) {
var docEl = doc.documentElement;
- var box = {};
- // The original object returned by getBoundingClientRect is immutable, so we clone it
- // We can't use extend because the properties are not considered part of the object by hasOwnProperty in IE9
- var rect = el.getBoundingClientRect();
- for (var k in rect) {
- box[k] = rect[k];
- }
+ var box = getActualBoundingClientRect(el);
var origin = getOrigin();
@@ -252,7 +272,9 @@ function hasClass(el, name) {
}
function getClassName(el) {
- if (el.className instanceof SVGAnimatedString) {
+ // Can't use just SVGAnimatedString here since nodes within a Frame in IE have
+ // completely separately SVGAnimatedString base classes
+ if (el.className instanceof el.ownerDocument.defaultView.SVGAnimatedString) {
return el.className.baseVal;
}
return el.className;
@@ -371,6 +393,7 @@ var Evented = (function () {
})();
TetherBase.Utils = {
+ getActualBoundingClientRect: getActualBoundingClientRect,
getScrollParents: getScrollParents,
getBounds: getBounds,
getOffsetParent: getOffsetParent,
@@ -429,7 +452,7 @@ var transformKey = (function () {
}
var el = document.createElement('div');
- var transforms = ['transform', 'webkitTransform', 'OTransform', 'MozTransform', 'msTransform'];
+ var transforms = ['transform', 'WebkitTransform', 'OTransform', 'MozTransform', 'msTransform'];
for (var i = 0; i < transforms.length; ++i) {
var key = transforms[i];
if (el.style[key] !== undefined) {
@@ -828,7 +851,7 @@ var TetherClass = (function (_Evented) {
this.enabled = true;
this.scrollParents.forEach(function (parent) {
- if (parent !== document) {
+ if (parent !== _this3.target.ownerDocument) {
parent.addEventListener('scroll', _this3.position);
}
});
@@ -1028,21 +1051,24 @@ var TetherClass = (function (_Evented) {
}
};
+ var doc = this.target.ownerDocument;
+ var win = doc.defaultView;
+
var scrollbarSize = undefined;
- if (document.body.scrollWidth > window.innerWidth) {
+ if (doc.body.scrollWidth > win.innerWidth) {
scrollbarSize = this.cache('scrollbar-size', getScrollBarSize);
next.viewport.bottom -= scrollbarSize.height;
}
- if (document.body.scrollHeight > window.innerHeight) {
+ if (doc.body.scrollHeight > win.innerHeight) {
scrollbarSize = this.cache('scrollbar-size', getScrollBarSize);
next.viewport.right -= scrollbarSize.width;
}
- if (['', 'static'].indexOf(document.body.style.position) === -1 || ['', 'static'].indexOf(document.body.parentElement.style.position) === -1) {
+ if (['', 'static'].indexOf(doc.body.style.position) === -1 || ['', 'static'].indexOf(doc.body.parentElement.style.position) === -1) {
// Absolute positioning in the body will be relative to the page, not the 'initial containing block'
- next.page.bottom = document.body.scrollHeight - top - height;
- next.page.right = document.body.scrollWidth - left - width;
+ next.page.bottom = doc.body.scrollHeight - top - height;
+ next.page.right = doc.body.scrollWidth - left - width;
}
if (typeof this.options.optimizations !== 'undefined' && this.options.optimizations.moveElement !== false && !(typeof this.targetModifier !== 'undefined')) {
@@ -1061,8 +1087,8 @@ var TetherClass = (function (_Evented) {
offsetBorder[side.toLowerCase()] = parseFloat(offsetParentStyle['border' + side + 'Width']);
});
- offsetPosition.right = document.body.scrollWidth - offsetPosition.left - offsetParentSize.width + offsetBorder.right;
- offsetPosition.bottom = document.body.scrollHeight - offsetPosition.top - offsetParentSize.height + offsetBorder.bottom;
+ offsetPosition.right = doc.body.scrollWidth - offsetPosition.left - offsetParentSize.width + offsetBorder.right;
+ offsetPosition.bottom = doc.body.scrollHeight - offsetPosition.top - offsetParentSize.height + offsetBorder.bottom;
if (next.page.top >= offsetPosition.top + offsetBorder.top && next.page.bottom >= offsetPosition.bottom) {
if (next.page.left >= offsetPosition.left + offsetBorder.left && next.page.right >= offsetPosition.right) {
@@ -1220,7 +1246,7 @@ var TetherClass = (function (_Evented) {
if (!offsetParentIsBody) {
this.element.parentNode.removeChild(this.element);
- document.body.appendChild(this.element);
+ this.element.ownerDocument.body.appendChild(this.element);
}
}
@@ -1280,12 +1306,22 @@ function getBoundingRect(tether, to) {
if (typeof to.nodeType !== 'undefined') {
(function () {
+ var node = to;
var size = getBounds(to);
var pos = size;
var style = getComputedStyle(to);
to = [pos.left, pos.top, size.width + pos.left, size.height + pos.top];
+ // Account any parent Frames scroll offset
+ if (node.ownerDocument !== document) {
+ var win = node.ownerDocument.defaultView;
+ to[0] += win.pageXOffset;
+ to[1] += win.pageYOffset;
+ to[2] += win.pageXOffset;
+ to[3] += win.pageYOffset;
+ }
+
BOUNDS_FORMAT.forEach(function (side, i) {
side = side[0].toUpperCase() + side.substr(1);
if (side === 'Top' || side === 'Left') {
Oops, something went wrong.
@@ -7341,7 +7341,7 @@ jQuery.param = function( a, traditional ) {
s[ s.length ] = encodeURIComponent( key ) + "=" + encodeURIComponent( value );
};
- // Set traditional to true for jQuery <= 1.3.2 behavior.
+ // Set traditional to true for jQuery <= 1.3.3 behavior.
if ( traditional === undefined ) {
traditional = jQuery.ajaxSettings && jQuery.ajaxSettings.traditional;
}
@@ -7354,7 +7354,7 @@ jQuery.param = function( a, traditional ) {
});
} else {
- // If traditional, encode the "old" way (the way 1.3.2 or older
+ // If traditional, encode the "old" way (the way 1.3.3 or older
// did it), otherwise encode params recursively.
for ( prefix in a ) {
buildParams( prefix, a[ prefix ], traditional, add );
@@ -7341,7 +7341,7 @@ jQuery.param = function( a, traditional ) {
s[ s.length ] = encodeURIComponent( key ) + "=" + encodeURIComponent( value );
};
- // Set traditional to true for jQuery <= 1.3.2 behavior.
+ // Set traditional to true for jQuery <= 1.3.3 behavior.
if ( traditional === undefined ) {
traditional = jQuery.ajaxSettings && jQuery.ajaxSettings.traditional;
}
@@ -7354,7 +7354,7 @@ jQuery.param = function( a, traditional ) {
});
} else {
- // If traditional, encode the "old" way (the way 1.3.2 or older
+ // If traditional, encode the "old" way (the way 1.3.3 or older
// did it), otherwise encode params recursively.
for ( prefix in a ) {
buildParams( prefix, a[ prefix ], traditional, add );
View
@@ -1,6 +1,6 @@
{
"name": "tether",
- "version": "1.3.2",
+ "version": "1.3.3",
"description": "A client-side library to make absolutely positioned elements attach to elements in the page efficiently.",
"authors": [
"Zack Bloom <zackbloom@gmail.com>",

0 comments on commit 7e43e95

Please sign in to comment.