Disabled button with span inside triggers click event
Are you requesting a feature or reporting a bug?
Bug.
What is the current behavior?
When you have disabled native button with span element inside, the click event is triggered in IE and Edge browsers.
What is the expected behavior?
Click event should not be triggered when a button is disabled.
How would you reproduce the current behavior (if this is a bug)?
- Create a disabled button with span element inside. Bind to the click event.
- Try to click it in IE/Edge browser.
Provide the test code and the tested page URL (if applicable)
<button disabled onclick="myFunction()">Click me</button>
<p id="demo"></p>
<script>
function myFunction() {
document.getElementById("demo").innerHTML = "Hello World";
}
</script>
Specify your
- operating system: Win7 - IE, Win10 - Edge
- testcafe version:
0.20.1 - node.js version:
8.9.4
I was able to reproduce the issue in Edge
fixed in https://github.com/DevExpress/testcafe-hammerhead/issues/1880
@AlexKamaev I am not sure if this fix is correct. Let me show you the example:
In the very simple case your fix is correct. No console log is called when the button is clicked (and it behaves the same in TestCafe):
<!-- Won't log anything -->
<div onclick="console.log('div')">
<button disabled onclick="console.log('button')">
Click me
</button>
</div>
On the other hand, when the disabled button contains any other element, the click events are called (but not in TestCafe!):
<!-- Logs "span" "div" -->
<div onclick="console.log('div')">
<button onclick="console.log('button')">
<span onclick="console.log('span')">Click me</span>
</button>
</div>
@palpatine1991 Thanks for the information. I see the inconsistency in this behavior. I'll reopen the issue.
I'll mark this issue as a duplicate since we have similar issue in the testcafe-hammerhead repository: DevExpress/testcafe#6949.
This thread has been automatically locked since it is closed and there has not been any recent activity. Please open a new issue for related bugs or feature requests. We recommend you ask TestCafe API, usage and configuration inquiries on StackOverflow.