Hi,
we found in dojod 1.10.4 a bug in djiit core.
This bug is potentially high risk, because it affects all dijits which have a disabled state.
To simulate the bug (see our code snippet below):
1. Put a dijit/form/Button on a simple html page
2. Use a onClick handler, which:
a. Set disabled=true
b. Run javascript code
c. Set disabled=false
3. First click on button
4. Button is now disabled
5. Click again on this disabled button
6. Check your console > the onClick handler runs twice!
code snippet:
<!DOCTYPE html>
<html>
<head>
<link href="../../../../../dijit/themes/claro/claro.css" media="screen,print" rel="stylesheet" type="text/css">
<style>
.dijitButtonDisabled .dijitButtonNode{
background-color: grey;
}
</style>
<script type="text/javascript"
src="../../../../../dojo/dojo.js"
data-dojo-config="basePath:'../../../../../', async: true, tlmSiblingOfDojo: 0, isDebug: 0, packages: [
{ name: 'dojo', location: '../dojo' },
{ name: 'dijit', location: '../dijit' }
]">
</script>
<script type="text/javascript">
require(["dojo/parser", "dojo/dom", "dijit/form/Button"], function (dojoParser, dom) {
dojoParser.parse({
rootNode: dom.byId("wrapperDiv")
});
});
function clickHandler(){
require(["dijit/registry"], function(reg){
reg.byId("buttonUnderTest").set("disabled", true); // Let's disable the Button until the Asyc-Request is finished
setTimeout(function (){ //Let's simulate an Async-Request
var j = 0;
console.log("Start of heavy Javascript Interaction");
for(var i = 0; i < 2000000000; i++){ //Small note: Depending on machine/browser you need to make the loop bigger/smaller
j++;
//Simulation of some heavy JavaScript-Interaction
//This is not needed for reproducing the bug,
//but without it the timeframe is too small to hit!
}
console.log("End of heavy Javascript Interaction");
reg.byId("buttonUnderTest").set("disabled", false); //We enable the Button again, so that the User can click again!
}, 0)
});
}
</script>
</head>
<body>
<div id="wrapperDiv">
<button data-dojo-type="dijit/form/Button"
id="buttonUnderTest"
type="button" onClick="clickHandler()">
Click me twice to see the bug!
</button>
<br>
<span>
After clicking the Button twice you will notice, that both of the console-logs will be shown twice.
The Click-Handler has run 2 times.</span>
</div>
</body>
</html>
I´d appreciate if you could open a ticket for this bug and let us know the ticket number.
Thanks a lot in advance.
Kind regards,
Bjoern
http://www.datev.de |
http://www.datev.com