W3C home > Mailing lists > Public > www-style@w3.org > August 2012

RE: Path to polyfilling CSS functions?

From: Sylvain Galineau <sylvaing@microsoft.com>
Date: Wed, 8 Aug 2012 02:25:06 +0000
To: Boris Smus <smus@google.com>, "www-style@w3.org" <www-style@w3.org>
Message-ID: <3C4041FF83E1E04A986B6DC50F0178291BE1FBFD@TK5EX14MBXC221.redmond.corp.microsoft.com>
Incidentally IE has supported a subset of your requirements in a rather natural way 
for many years. If you have something like:

<!doctype html>
	#test {
		another: baz, even;
<div id="test"></div>
	var test = getComputedStyle(document.getElementById('test'));

IE will alert 'bar' and 'baz, even'. We essentially cascade these unknown 
properties as name-value pairs. Figuring out whether the property is unknown 
does take a little more work e.g. instantiating a blank node and checking 
whether it's defined in the style property. There is no support for inheritance 
so have to roll it out yourself. But though it's simple it can be quite handy. 
I often wish other browsers did the same.

Of course this doesn't make polyfilling functions or other extension to existing
properties easy but that is a more complex problem to solve generally anyway: 
instead of parsing either known or unknown values we now have 'values unknown 
to the browser but known to the app', 'values unknown to everyone' and even 
'values both the browser and the app want to do something with'... And we can't 
really tell which is which at parse-time without you somehow telling us before 
we load the stylesheets that use said values, even before there is a DOM. (I 
assume here we're not changing the CSS error handling model)

You could still use the IE model to polyfill image() by prefixing the properties 
you're extending - e.g. xbackground - and either handle the whole value yourself 
or pass the 'safe' standard bits back to the 'real' property already exposed by 
the browser, as needed. For the reasons mentioned by Tab (among others) I don't 
think that's necessarily bad: you can add non-inheritable properties very simply 
and you could use the same mechanism to experiment with extensions to existing 
properties in some side namespace if you're willing to put in the work.

Of course there are other things to consider such as the ability to detect value 
changes but based on my positive experiences using this IE capability I wonder if 
a simple approach could still be a helpful first step, especially combined with 
Received on Wednesday, 8 August 2012 02:25:39 UTC

This archive was generated by hypermail 2.4.0 : Friday, 25 March 2022 10:08:20 UTC