Skip to content

Commit

Permalink
fix: text events propagate out of shadow root. (#19132)
Browse files Browse the repository at this point in the history
  • Loading branch information
sainthkh authored Dec 2, 2021
1 parent 6b19381 commit f85c736
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 0 deletions.
25 changes: 25 additions & 0 deletions packages/driver/cypress/fixtures/shadow-dom-type.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<html>
<body>
<test-element id="element"></test-element>
<div id="result"></div>
</body>
<script>
class TestElement extends HTMLElement {
constructor() {
super();
this._shadow = this.attachShadow({mode: "open"});

const input = document.createElement("input");
this._shadow.appendChild(input);
}
}

customElements.define("test-element", TestElement);

const el = document.getElementById("element");

el.addEventListener('keydown', () =>{
document.getElementById('result').innerText = 'typed'
})
</script>
</html>
11 changes: 11 additions & 0 deletions packages/driver/cypress/integration/commands/actions/type_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3592,5 +3592,16 @@ describe('src/cy/commands/actions/type - #type', () => {
.find('input', { includeShadowDom: true })
.type('foo')
})

// https://github.com/cypress-io/cypress/issues/17531
it('text events propagate out of shadow root', () => {
cy.visit('fixtures/shadow-dom-type.html')

cy
.get('test-element').shadow()
.find('input').type('asdf')

cy.get('#result').should('have.text', 'typed')
})
})
})
3 changes: 3 additions & 0 deletions packages/driver/src/cy/keyboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -960,6 +960,9 @@ export class Keyboard {
..._.omitBy(
{
bubbles: true,
// allow propagation out of root of shadow-dom
// https://developer.mozilla.org/en-US/docs/Web/API/Event/composed
composed: true,
cancelable,
key,
code,
Expand Down

3 comments on commit f85c736

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on f85c736 Dec 2, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the linux x64 version of the Test Runner.

Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/9.1.1/circle-develop-f85c736d3e493ec052cf6c94e25854ccf279ac30/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on f85c736 Dec 2, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AppVeyor has built the win32 x64 version of the Test Runner.

Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/9.1.1/appveyor-develop-f85c736d3e493ec052cf6c94e25854ccf279ac30/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on f85c736 Dec 2, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the darwin x64 version of the Test Runner.

Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/9.1.1/circle-develop-f85c736d3e493ec052cf6c94e25854ccf279ac30/cypress.tgz

Please sign in to comment.