W3C home > Mailing lists > Public > public-webapps@w3.org > April to June 2010

Re: Extending CSSOM Views matchMedium with callback

From: L. David Baron <dbaron@dbaron.org>
Date: Mon, 10 May 2010 10:56:41 -0700
To: Simon Fraser <smfr@me.com>
Cc: Luiz Agostini <luiz.agostini@openbossa.org>, public-webapps@w3.org, www-style@w3.org
Message-ID: <20100510175641.GA18930@pickering.dbaron.org>
On Monday 2010-05-10 10:27 -0700, Simon Fraser wrote:
> This simple callback-based mechanism suffers from various problems (of the type
> that add/removeEventListener were designed to solve):
> 1. Unclear behavior when calling matchMedium() a second time for the same query,
> with a different callback.
> 2. No way to remove a callback
> 3. Lack of context on the callback

Right.  These are problems.

> It feels to me like the correct solution would be enhance CSS OM somehow to allow
> authors to attach event listeners to CSSMediaRules somehow, so they can get notified
> when those @media statements start or stop matching.

Making @media rules implement EventTarget sounds ok, as long as the
events don't bubble.  But is the main use case for this API actually
people who already have @media rules, or people who want to do
things separately from @media rules and would thus now have to go
through the bother of adding some to a style sheet?  (The CSSOM also
isn't very good at giving you the rule object after adding a rule.)

I might still lean towards an
addMediaQueryListener/removeMediaQueryListener type API.


L. David Baron                                 http://dbaron.org/
Mozilla Corporation                       http://www.mozilla.com/
Received on Monday, 10 May 2010 17:57:16 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 18:13:07 UTC