Re: why not MediaQueryList.onchange

On Mon, 19 May 2014 14:13:48 +0200, Tab Atkins Jr. <jackalmage@gmail.com>  
wrote:

> * alias the existing addListener(...) to addEventListener("change",
> ...); same with removeListener()

I looked into changing this in the spec and noticed that this would change  
the argument of the callback from the MediaQueryList object to the event,  
which is potentially a Web compat problem.

For instance http://www.cafepress.ca/ uses:

 cafepress.globalHeader.matchMedia(570, function(mq){
  if(!gtmLoaded) {
   if(!mq || !mq.matches) {

This can be solved by minting a new event interface that has .media and  
.matches.

It would still break if a page uses e.g. removeListener on the callback's  
argument, or does other things like type-check the argument, but maybe  
that's not common enough to worry about.

-- 
Simon Pieters
Opera Software

Received on Friday, 6 June 2014 09:20:52 UTC