Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[synthetic shadow] elementsFromPoint does not return all elements #2495

Closed
nolanlawson opened this issue Sep 15, 2021 · 1 comment · Fixed by #2534
Closed

[synthetic shadow] elementsFromPoint does not return all elements #2495

nolanlawson opened this issue Sep 15, 2021 · 1 comment · Fixed by #2534
Labels

Comments

@nolanlawson
Copy link
Collaborator

Description

When @lwc/synthetic-shadow is loaded, document.elementsFromPoint does not always return the full list of elements (compared to native shadow).

This can cause problems for tools like Chromedriver that use elementsFromPoint to figure out if an element is visible or not. With synthetic shadow loaded, this can cause Chromedriver to believe an element is not visible when it actually is.

Steps to Reproduce

Minimal repro

In the repro, the top-level component has the following styles:

:host {
    width: 0;
    height: 0;
    position: absolute;
}

This causes it to not be returned in elementsFromPoint, but only in synthetic shadow.

Expected vs Actual Results

In synthetic shadow, only <html> is returned from document.elementsFromPoint, whereas with native shadow, both <html> and <x-app> are returned.

Screen Shot 2021-09-15 at 1 56 38 PM

Browsers Affected

Chrome v93, Firefox v92. (native works, synthetic fails)

Safari v14.1 returns both elements in both synthetic and native. (synthetic and native both work)

Version

LWC v2.4.0

Possible Solution

Avoid elementsFromPoint, i.e. avoid Chromedriver APIs that rely on this (such as moveTo).

@uip-robot-zz
Copy link

This issue has been linked to a new work item: W-9904840

nolanlawson added a commit that referenced this issue Jan 10, 2022
* fix(synthetic-shadow): elementsFromPoint returns invisible hosts

Fixes #2495

W-9904840

* fix: only consider immediate shadow root

* fix: optimize impl a bit

* fix: fix missing array methods

* test: make test more consistent across browsers

* test: tidy up test

* test: disable test for ie11

* fix: extract function to outer scope
nolanlawson added a commit that referenced this issue Jan 14, 2022
* fix(synthetic-shadow): elementsFromPoint returns invisible hosts

Fixes #2495

W-9904840

* fix: only consider immediate shadow root

* fix: optimize impl a bit

* fix: fix missing array methods

* test: make test more consistent across browsers

* test: tidy up test

* test: disable test for ie11

* fix: extract function to outer scope
nolanlawson added a commit that referenced this issue Jan 14, 2022
* fix(synthetic-shadow): elementsFromPoint returns invisible hosts

Fixes #2495

W-9904840

* fix: only consider immediate shadow root

* fix: optimize impl a bit

* fix: fix missing array methods

* test: make test more consistent across browsers

* test: tidy up test

* test: disable test for ie11

* fix: extract function to outer scope
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants