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

fix: Add tests for shadow dom traversal methods, fix issues #8202

Merged
merged 7 commits into from
Aug 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 22 additions & 6 deletions packages/driver/cypress/fixtures/shadow-dom.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,38 @@
<head>
<title>Shadow DOM Fixture</title>
</head>
<body>
<body class="filter-me">
<div id="non-shadow-element" class="in-and-out">Non Shadow</div>
<cy-test-element id="shadow-element-1" innerClass="shadow-1" content="Shadow Content 1"></cy-test-element>
<cy-test-element id="shadow-element-2" innerClass="shadow-2" content="Shadow Content 2"></cy-test-element>
<div id="parent-of-shadow-container-0">
<div id="parent-of-shadow-container-1">
<div id="parent-of-shadow-container-1" class="filter-me">
<cy-test-element id="shadow-element-3" innerClass="shadow-3" content="Shadow Content 3"></cy-test-element>
</div>
</div>
<cy-test-element innerClass="shadow-4" content="Shadow Content 4">
<cy-test-element innerClass="shadow-5" content="Shadow Content 5"></cy-test-element>
<cy-test-element id="shadow-element-4" innerClass="shadow-4" content="Shadow Content 4">
<cy-test-element id="shadow-element-5" innerClass="shadow-5" content="Shadow Content 5"></cy-test-element>
</cy-test-element>
<cy-test-element innerClass="shadow-6" content="Shadow Content 6">
<div class="in-shadow-slot">In Shadow Slot</div>
</cy-test-element>
<cy-test-element id="shadow-element-7" innerClass="in-and-out" content="Shadow Content 7"></cy-test-element>
<div id="parent-of-shadow-container-2">
<div id="parent-of-shadow-container-3" class="filter-me">
<cy-test-element id="shadow-element-8" content="
<span class='shadow-8-nested-1 filter-me'>
<span class='shadow-8-nested-2'>
<span class='shadow-8-nested-3 shadow-8-nested'>Shadow </span>
<span class='shadow-8-nested-4 shadow-8-nested'>Content </span>
<span class='shadow-8-nested-5 shadow-8-nested'>8</span>
</span>
</span>
"></cy-test-element>
</div>
</div>
<cy-test-element id="shadow-element-9" content="Shadow Content 9" rootAddition="
<div class='shadow-div'>Shadow Content 9</div>
"></cy-test-element>

<script type="text/javascript">
if (window.customElements) {
Expand All @@ -27,11 +43,11 @@
super()

const root = this.attachShadow({ mode: 'open' })
const para = document.createElement('p')
const content = this.getAttribute('content')
const className = this.hasAttribute('innerClass') ? this.getAttribute('innerClass') : 'shadow-content'
const rootAddition = this.hasAttribute('rootAddition') ? this.getAttribute('rootAddition') : 'shadow-content'

root.innerHTML = `<p class="${className}">${content}</p><input /><slot></slot>`
root.innerHTML = `<div class="shadow-div"><p class="${className}">${content}</p><input /><slot></slot></div>${rootAddition}`
}
})
}
Expand Down
Loading