Skip to content

Commit 1548047

Browse files
authored
fix: non-HTMLElement(s) fail during assertions (#30947)
1 parent e06c846 commit 1548047

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

cli/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ _Released 1/28/2025 (PENDING)_
66
**Bugfixes:**
77

88
- Fixed an issue where Cypress would incorrectly navigate to `about:blank` when test isolation was disabled and the last test would fail and then retry. Fixes [#28527](https://github.com/cypress-io/cypress/issues/28527).
9+
- Fixed an issue where non-HTMLElement(s) may fail during assertions. Fixes [#30944](https://github.com/cypress-io/cypress/issues/30944)
910

1011
**Misc:**
1112

packages/driver/cypress/e2e/commands/assertions.cy.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -939,6 +939,17 @@ describe('src/cy/commands/assertions', () => {
939939
expect(2n).to.equal(2n)
940940
})
941941

942+
it('handles non-HTMLElement(s) (e.g. Element)', () => {
943+
const xml = '<?xml version="1.0" encoding="UTF-8"?><foo><bar>Bar</bar></foo>'
944+
const parser = new DOMParser()
945+
const doc = parser.parseFromString(xml, 'application/xml')
946+
const foo = doc.getElementsByTagName('foo')[0]
947+
948+
expect(foo).not.to.be.undefined
949+
expect(foo).to.be.instanceOf(Element)
950+
expect(foo).not.to.be.instanceOf(HTMLElement)
951+
})
952+
942953
it('#consoleProps for regular objects', (done) => {
943954
cy.on('log:added', (attrs, log) => {
944955
if (attrs.name === 'assert') {

packages/driver/src/dom/visibility.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -130,13 +130,11 @@ const elHasNoEffectiveWidthOrHeight = ($el: JQuery) => {
130130
// display:none elements, and generally any elements that are not directly rendered,
131131
// an empty list is returned.
132132
const el = $el[0]
133-
let transform
134133

135-
if ($el[0].style.transform) {
136-
const style = getComputedStyle(el)
134+
const style = getComputedStyle(el)
135+
let transform = style.getPropertyValue('transform')
137136

138-
transform = style.getPropertyValue('transform')
139-
} else {
137+
if (!transform.length) {
140138
transform = 'none'
141139
}
142140

0 commit comments

Comments
 (0)