Event listeners not working in custom elements
See original GitHub issueCurrent behavior
An event emitted from an element inside of the shadow DOM does not trigger an event listener in a parent custom element. The DOM in my example is as follows:
page-element
(a custom element)text-input
(another custom element)input
input
The page-element
has an event listener on the text-input
for an input
event which removes the disabled
attribute from the input
element in the shadow DOM of the page-element
. When tested in Cypress, the disabled
attribute is never removed, however strangely if I run the test with cypress open
and type in the input field myself after the test completes, the disabled
attribute is removed instantly. I put in a 10 second wait after visit
to make sure all the components are loaded and connected. Result in my example below is as follows:
Test event listeners
1) makes sure event listener works
0 passing (15s)
1 failing
1) Test event listeners
makes sure event listener works:
AssertionError: Timed out retrying after 4000ms: expected '[ <input>, 1 more... ]' not to have attribute 'disabled'
at Context.eval (http://localhost:63324/__cypress/tests?p=cypress\integration\spec.js:103:25)
Desired behavior
The test should cause the disabled
attribute in the input
element with type=submit
to be removed.
Test code to reproduce
Clone this fork:
https://github.com/jrtcppv/cypress-test-tiny
Run the following:
npm install cypress
./node_modules/bin/cypress run
Cypress Version
7.7.0, 8.0.0, 8.1.0
Other
Really want Cypress to work for us, but our application has a ton of nested custom elements like this… hopefully this example will give us some insight into what the problem is. I’m also a Cypress noob so possible I am just doing something wrong.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:2
- Comments:7
Top GitHub Comments
Sorry for another misunderstanding.
Cypress emulates the type events by sending them programatically. And I learned that the input message isn’t sent to the elements under
shadow
root.Confirmed that the bug happens.
Released in
9.1.1
.This comment thread has been locked. If you are still experiencing this issue after upgrading to Cypress v9.1.1, please open a new issue.