Skip to content

Commit

Permalink
Expand check for offset parents to also check children of ancestor fo…
Browse files Browse the repository at this point in the history
…r positioning attributes

close #4395
close #755
  • Loading branch information
jennifer-shehane committed Jun 17, 2019
1 parent 28185e9 commit ded5e9f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
6 changes: 6 additions & 0 deletions packages/driver/src/dom/elements.js
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,10 @@ const isAncestor = ($el, $maybeAncestor) => {
return $el.parents().index($maybeAncestor) >= 0
}

const isChild = ($el, $maybeChild) => {
return $el.children().index($maybeChild) >= 0
}

const isSelector = ($el, selector) => {
return $el.is(selector)
}
Expand Down Expand Up @@ -818,6 +822,8 @@ module.exports = {

isAncestor,

isChild,

isScrollable,

isTextLike,
Expand Down
5 changes: 2 additions & 3 deletions packages/driver/src/dom/visibility.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,9 @@ const canClipContent = function ($el, $ancestor) {
const $offsetParent = $jquery.wrap($el[0].offsetParent)

// even if overflow is clippable, if the element's offset parent
// is a parent of the ancestor, the ancestor will not clip the element
// is a parent or child of the ancestor, the ancestor will not clip the element
// unless the element is position relative
if (!elHasPositionRelative($el) && $elements.isAncestor($ancestor, $offsetParent)) {
if (!elHasPositionRelative($el) && ($elements.isAncestor($ancestor, $offsetParent) || $elements.isChild($ancestor, $offsetParent))) {
return false
}

Expand Down Expand Up @@ -399,7 +399,6 @@ const getReasonIsHidden = function ($el) {
return `This element '${node}' is not visible because it has CSS property: 'visibility: collapse'`
}

return `This element '${node}' is not visible because it has an effective width and height of: '${width} x ${height}' pixels.`
if (elHasNoOffsetWidthOrHeight($el)) {
return `This element '${node}' is not visible because it has an effective width and height of: '${width} x ${height}' pixels.`
}
Expand Down

0 comments on commit ded5e9f

Please sign in to comment.