Skip to content

Commit

Permalink
Merge pull request shipshapecode#204 from pzuraq/adds-option-to-speci…
Browse files Browse the repository at this point in the history
…fy-body-element

Adds option to specify body element
  • Loading branch information
TrevorBurnham authored Dec 2, 2016
2 parents 74256cc + 4de1f5c commit 3d7119e
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 28 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tether",
"version": "1.3.9",
"version": "1.4.0",
"homepage": "http://github.hubspot.com/tether",
"authors": [
"Zack Bloom <[email protected]>",
Expand Down
30 changes: 17 additions & 13 deletions dist/js/tether.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! tether 1.3.9 */
/*! tether 1.4.0 */

(function(root, factory) {
if (typeof define === 'function' && define.amd) {
Expand Down Expand Up @@ -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);
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion dist/js/tether.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>",
Expand Down
28 changes: 16 additions & 12 deletions src/js/tether.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}

Expand Down

0 comments on commit 3d7119e

Please sign in to comment.