Created
July 12, 2016 01:00
-
-
Save msr1k/f43cbd6fe9dd1f6b617b0e162b14c2b0 to your computer and use it in GitHub Desktop.
Check JavaScript Message Queue Behavior: Particularly UI Event filtering timing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <script src="http://code.jquery.com/jquery-1.11.1.min.js"></script> | |
| <button id="a" onclick="A();">asdf</button> | |
| <button id="b" onclick="B();">zxcv</button> | |
| <script> | |
| function C () { | |
| for ( var i = 0; i < 65535; i += 2 ) { | |
| i = i - 1; | |
| } | |
| } | |
| function A () { | |
| console.log( "A starts" ); | |
| setTimeout( function () { | |
| $("#b").prop( "disabled", true ); | |
| }, 1000 ); | |
| for ( var i = 0; i < 65535; i++ ) { | |
| C(); | |
| } | |
| console.log( "A ends" ); | |
| } | |
| function B () { | |
| console.log( "B starts" ); | |
| // $("#a").prop( "disabled", true ); | |
| // $("#a").click(); | |
| console.log( "B ends" ); | |
| } | |
| </script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment