- From: Richard Gibson <richard.gibson@gmail.com>
- Date: Thu, 19 Nov 2015 08:58:31 -0500
- To: www-style@w3.org
- Message-ID: <CALH+fvpNMJ2TCaj4QHCA1TH-HfwgvcXugm+zMChY2rztSgbQJA@mail.gmail.com>
I'm adding a selector escape function to Sizzle (the selection library backing jQuery), and originally planned to match https://drafts.csswg.org/cssom/#the-css.escape()-method but ran into a snag regarding U+0000 NULL [1]. The draft calls for throwing an InvalidCharacterError exception in §2.1, but that doesn't fit with our library. It doesn't seem to fit within CSS, either, though. \0 is a valid escape per CSS Syntax [2], although it is returned as U+FFFD REPLACEMENT CHARACTER, and all major browsers but one now respect it (e.g., jQuery("<div><span data-attr='�'/></div>")[0].querySelector("[data-attr='\\0 ']") returns the span)—the holdout is Safari, in which [data-attr='\\0 '] is treated as valid but never matches anything. So I'm wondering if you'd be willing to escape NULL rather than throwing an exception. And if not, perhaps you could shed some light on why the exception was added in the first place? A brief history of NULL: * 2010 dbaron includes NULL in proposed escaping language (presumably as "\0 "): https://lists.w3.org/Archives/Public/www-style/2010Feb/0162.html * 2011 CSSOM WD includes escaping NULL: http://www.w3.org/TR/2011/WD-cssom-20110712/#common-serializing-idioms * 2012 (not directly related) Tab suggests a codification in input preprocessing of replacement with U+FFFD REPLACEMENT CHARACTER: https://lists.w3.org/Archives/Public/www-style/2012Oct/0687.html * 2013 CSSOM WD introduces InvalidCharacterError exceptions for escaping NULL (rethrown by CSS.escape): http://www.w3.org/TR/2013/WD-cssom-20131205/#common-serializing-idioms * 2015 no change: https://drafts.csswg.org/cssom/#common-serializing-idioms [1] https://github.com/jquery/sizzle/pull/364#discussion_r44619782 [2] http://www.w3.org/TR/2014/CR-css-syntax-3-20140220/#consume-an-escaped-code-point0 and http://www.w3.org/TR/2014/CR-css-syntax-3-20140220/#escaping
Received on Sunday, 22 November 2015 20:22:09 UTC