Draft
Conversation
…ility CSS properties The isElementVisible function previously only checked for display:none and offsetParent, missing elements hidden via other CSS methods. Now it also checks: - visibility: hidden/collapse (including inherited from ancestors) - opacity: 0 - content-visibility: hidden Added WTR test cases covering all these hiding methods, including edge cases like fixed-position hidden elements and visible children inside visibility:hidden parents. Co-authored-by: Sam Macbeth <sammacbeth@users.noreply.github.com>
|
Cursor Agent can help with this pull request. Just |
Co-authored-by: Sam Macbeth <sammacbeth@users.noreply.github.com>
…isElementVisible Co-authored-by: Sam Macbeth <sammacbeth@users.noreply.github.com>
…llback Replace the manual getComputedStyle-based checks with the native checkVisibility() API (checkVisibilityCSS + checkOpacity), falling back to the manual approach for browsers that lack it. This correctly handles ancestor opacity:0 and ancestor content-visibility:hidden, which the previous implementation missed. Add test cases for ancestor hiding via opacity:0 and content-visibility:hidden. Correct the content-visibility:hidden element-self test: the element's own box is still visible, only its content is hidden, so checkVisibility() rightly returns true. Remove stale 'check for display: none' comment in dom-actions.ts. Co-authored-by: Sam Macbeth <sammacbeth@users.noreply.github.com>
elementVisible now temporarily disables the autoconsent-prehide stylesheet before checking visibility, so that elements hidden by autoconsent's own prehide (opacity: 0) are still detected as visible during popup detection. Elements hidden by other means remain correctly reported as not visible. Added test cases covering: - prehidden visible element is still reported as visible - prehidden already-hidden element is still reported as not visible - element remains visible after undoPrehide Co-authored-by: Sam Macbeth <sammacbeth@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Task/Issue URL: N/A
Description
Updates the
isElementVisiblefunction to use the nativeElement.checkVisibility()API (with a manual fallback for older browsers), replacing the previousgetComputedStyle+offsetParentapproach. This correctly detects elements hidden viavisibility: hidden,opacity: 0,content-visibility: hidden, and ancestor hiding -- not justdisplay: none.Additionally,
elementVisibleinDomActionsnow temporarily disables the autoconsent prehide stylesheet before checking visibility, so that elements hidden by autoconsent's own prehide (opacity: 0) are still detected as visible during popup detection.Changes
lib/utils.ts:isElementVisibleusescheckVisibility({ checkVisibilityCSS: true, checkOpacity: true })as the primary path, with a manualgetComputedStylefallback for environments without it.lib/dom-actions.ts:elementVisibletemporarily disables theautoconsent-prehidestylesheet during visibility checks so prehidden popups are still detected. Removed stale comment.tests-wtr/dom-actions/dom-actions.element-visible.{html,ts}: Added test cases for:display: none,visibility: hidden,visibility: collapse,opacity: 0,content-visibility: hiddenvisibility: hidden,opacity: 0,content-visibility: hiddenvisibility: visiblechild overridingvisibility: hiddenparentundoPrehideSteps to test this PR
npm run test:libdom-actions.element-visible.tsNote: The
rule-compactiontest failure (expected 2861 to equal 2860) is pre-existing and unrelated to these changes.