Skip to content
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
1 change: 1 addition & 0 deletions cli/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ _Released 12/16/2025 (PENDING)_
- Fixed an issue where the browser would freeze when Cypress intercepts a synchronous XHR request and a `routeHandler` is used. Fixes [#32874](https://github.com/cypress-io/cypress/issues/32874). Addressed in [#32925](https://github.com/cypress-io/cypress/pull/32925).
- Fixed an issue where `Next.js` Component Testing would not load correctly without a TypeScript-based Next config in versions 16.0.3 and up. Fixes [#32968](https://github.com/cypress-io/cypress/issues/32968).
- Fixed an issue where the error message for `not.have.length` was not correctly displaying the expected length in the Command Log. Addressed in [#18927](https://github.com/cypress-io/cypress/issues/18927).
- Fixed an issue where `removeAttribute()` would not work for attributes other than `target` on anchor or form elements after clicking links with `target="_top"` or `target="_parent"`. Fixes [#26206](https://github.com/cypress-io/cypress/issues/26206). Addressed in [#33051](https://github.com/cypress-io/cypress/pull/33051).

## 15.7.1

Expand Down
14 changes: 14 additions & 0 deletions packages/driver/cypress/e2e/issues/26206.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// https://github.com/cypress-io/cypress/issues/26206
describe('issue 26206', () => {
beforeEach(() => {
cy.visit('fixtures/issue-26206.html')
})

it('removeAttribute works for non-target attributes after handleInvalidTarget', () => {
// After clicking an anchor with target="_top", the handleInvalidTarget function
// patches the element's removeAttribute. The bug was that removeAttribute
// would not work for attributes other than 'target'.
cy.get('#link').click()
cy.get('#result').should('have.text', 'removed')
})
})
18 changes: 18 additions & 0 deletions packages/driver/cypress/fixtures/issue-26206.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!DOCTYPE html>
<html lang="en">
<head>
</head>
<body>
<script>
function removeNonTargetAttribute(e) {
e.target.removeAttribute('data-bar')
document.getElementById('result').innerHTML = e.target.hasAttribute('data-bar') ? 'has-attribute' : 'removed'
}
</script>

<div>
<a href="#" id="link" target="_top" data-bar="baz" onclick="removeNonTargetAttribute(event)">link</a>
<div id="result"></div>
</div>
</body>
</html>
6 changes: 3 additions & 3 deletions packages/driver/src/cy/top_attr_guards.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,10 @@ export function handleInvalidTarget (el: HTMLFormElement | HTMLAnchorElement) {
if (k === 'target') {
targetSet = false
targetValue = ''

// We're not using `$elements.callNativeMethod` here because it disallows `removeAttribute`.
return removeAttribute.call(this, k)
}

// We're not using `$elements.callNativeMethod` here because it disallows `removeAttribute`.
return removeAttribute.call(this, k)
}

if (!targetDescriptor) {
Expand Down