Permalink
Browse files

Adds option to specify body element

  • Loading branch information...
1 parent 74256cc commit 4de1f5cb421e0e6149269a347ee261b06bdbd139 Christopher Garrett committed with pzuraq Aug 29, 2016
Showing with 36 additions and 28 deletions.
  1. +1 −1 bower.json
  2. +17 −13 dist/js/tether.js
  3. +1 −1 dist/js/tether.min.js
  4. +1 −1 package.json
  5. +16 −12 src/js/tether.js
View
@@ -1,6 +1,6 @@
{
"name": "tether",
- "version": "1.3.9",
+ "version": "1.4.0",
"homepage": "http://github.hubspot.com/tether",
"authors": [
"Zack Bloom <zackbloom@gmail.com>",
View
@@ -1,4 +1,4 @@
-/*! tether 1.3.9 */
+/*! tether 1.4.0 */
(function(root, factory) {
if (typeof define === 'function' && define.amd) {
@@ -1247,20 +1247,24 @@ var TetherClass = (function (_Evented) {
}
if (!moved) {
- var offsetParentIsBody = true;
- var currentNode = this.element.parentNode;
- while (currentNode && currentNode.nodeType === 1 && currentNode.tagName !== 'BODY') {
- if (getComputedStyle(currentNode).position !== 'static') {
- offsetParentIsBody = false;
- break;
- }
+ if (this.options.bodyElement) {
+ this.options.bodyElement.appendChild(this.element);
+ } else {
+ var offsetParentIsBody = true;
+ var currentNode = this.element.parentNode;
+ while (currentNode && currentNode.nodeType === 1 && currentNode.tagName !== 'BODY') {
+ if (getComputedStyle(currentNode).position !== 'static') {
+ offsetParentIsBody = false;
+ break;
+ }
- currentNode = currentNode.parentNode;
- }
+ currentNode = currentNode.parentNode;
+ }
- if (!offsetParentIsBody) {
- this.element.parentNode.removeChild(this.element);
- this.element.ownerDocument.body.appendChild(this.element);
+ if (!offsetParentIsBody) {
+ this.element.parentNode.removeChild(this.element);
+ this.element.ownerDocument.body.appendChild(this.element);
+ }
}
}
Oops, something went wrong.
View
@@ -1,6 +1,6 @@
{
"name": "tether",
- "version": "1.3.9",
+ "version": "1.4.0",
"description": "A client-side library to make absolutely positioned elements attach to elements in the page efficiently.",
"authors": [
"Zack Bloom <zackbloom@gmail.com>",
View
@@ -759,20 +759,24 @@ class TetherClass extends Evented {
}
if (!moved) {
- let offsetParentIsBody = true;
- let currentNode = this.element.parentNode;
- while (currentNode && currentNode.nodeType === 1 && currentNode.tagName !== 'BODY') {
- if (getComputedStyle(currentNode).position !== 'static') {
- offsetParentIsBody = false;
- break;
- }
+ if (this.options.bodyElement) {
+ this.options.bodyElement.appendChild(this.element);
+ } else {
+ let offsetParentIsBody = true;
+ let currentNode = this.element.parentNode;
+ while (currentNode && currentNode.nodeType === 1 && currentNode.tagName !== 'BODY') {
+ if (getComputedStyle(currentNode).position !== 'static') {
+ offsetParentIsBody = false;
+ break;
+ }
- currentNode = currentNode.parentNode;
- }
+ currentNode = currentNode.parentNode;
+ }
- if (!offsetParentIsBody) {
- this.element.parentNode.removeChild(this.element);
- this.element.ownerDocument.body.appendChild(this.element);
+ if (!offsetParentIsBody) {
+ this.element.parentNode.removeChild(this.element);
+ this.element.ownerDocument.body.appendChild(this.element);
+ }
}
}

0 comments on commit 4de1f5c

Please sign in to comment.