W3C home > Mailing lists > Public > www-style@w3.org > June 2014

Re: why not MediaQueryList.onchange

From: Simon Pieters <simonp@opera.com>
Date: Fri, 06 Jun 2014 11:20:34 +0200
To: "Jochen Eisinger" <eisinger@google.com>, "Tab Atkins Jr." <jackalmage@gmail.com>
Cc: "www-style list" <www-style@w3.org>
Message-ID: <op.xg0z8kjgidj3kv@simons-mbp>
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

This archive was generated by hypermail 2.3.1 : Monday, 2 May 2016 14:39:22 UTC