- From: Jacob Rossi <jrossi@microsoft.com>
- Date: Sat, 2 Apr 2011 00:35:12 +0000
- To: "www-style@w3.org" <www-style@w3.org>
For the MediaQueryList interface, the spec does not currently define the behavior for callback reentrancy (at least not explicitly). Consider the following example: 1. A MQL has 3 listeners: A, B, and C 2. The evaluation of the mql changes from false to true, so the dispatching of callbacks begins. 3. Invoke A 4. Invoke B i. B executes script which causes the evaluation of the mql to change to false At this point, do you a) begin a reentrant dispatch of A/B/C for the new change and then pick up where you left off afterwards (this is how DOM Events behaves), b) wait until you've invoked C and then dispatch A/B/C for the new change, c) or do you abort the current dispatch (do not invoke C) and begin a new dispatch A/B/C for the new change? My suggestion is option B. In order to avoid messing up potential state machines and such that developers might build, it's important that C still get a callback with .matches equal to true. After all three callbacks have been made, a new dispatch begins for A,B, and C with .matches equal to false. I believe this can be accomplished by expanding on the second sentence of section 3.1 to say: The value of the matches property must be fixed during the invocation of the list of media query list listeners. With this text, then the behavior for the above scenario is: 1. Invoke A (matches==true) 2. Invoke B (matches==true) 3. Invoke C (matches==true) 4. Invoke A (matches==false) 5. Invoke B (matches==false) 6. Invoke C (matches==false) An example to this effect might also be useful in the spec. --Jacob Rossi [MSFT]
Received on Saturday, 2 April 2011 00:35:53 UTC