- From: Tab Atkins Jr. <jackalmage@gmail.com>
- Date: Tue, 18 Dec 2012 12:37:14 -0800
- To: Peter Linss <peter.linss@hp.com>
- Cc: "L. David Baron" <dbaron@dbaron.org>, John Daggett <jdaggett@mozilla.com>, www-style list <www-style@w3.org>
On Tue, Dec 18, 2012 at 12:28 PM, Peter Linss <peter.linss@hp.com> wrote: > Right but it fails if the author does something like: > > declaration.setProperty("FONT-FAMILY", "serif", ""); > declaration.setProperty("FONT-WEIGHT", "700", ""); > for (var i = 0; i < declaration.length; ++i) { > var prop = declaration[i]; > if (prop == "FONT-FAMILY") { > // do something > } else if (prop == "FONT-WEIGHT") { > // do something else > } > } Luckily, that immediately fails today, so authors quickly find out that it's wrong. > I think the best way to handle this is going to require adding an API to do identifier matching via script in whatever the proper way to match that identifier is, something like: > > declaration.setProperty("FONT-FAMILY", "serif", ""); > declaration.setProperty("FONT-WEIGHT", "700", ""); > for (var i = 0; i < declaration.length; ++i) { > var prop = declaration[i]; > if (CompareCSSIdent(prop, "FONT-FAMILY")) { > // do something > } else if (CompareCSSIdent(prop, "FONT-WEIGHT")) { > // do something else > } > } > > And then the actual comparison function can do whatever the proper matching algorithm expects, be it case-senitivity, ascii case-insensitivity, or some form of unicode insensitivity (and possibly normalization). We can have different functions for each type of matching. This also allows the browser to store only a normalized form. > > We should probably also add an API that normalizes the string appropriately, such as: > var ident = NormalizeCSSIdent("FONT-weight"); I'm not opposed to these if it proves necessary, but I'm happy to wait and see. ~TJ
Received on Tuesday, 18 December 2012 20:38:07 UTC