W3C home > Mailing lists > Public > www-style@w3.org > April 2008

[SelectorsAPI] Selector detection needed?

From: Nicholas C. Zakas <html@nczonline.net>
Date: Sun, 6 Apr 2008 01:36:07 -0700 (PDT)
To: www-style@w3.org
Message-ID: <707839.12112.qm@web57712.mail.re3.yahoo.com>

Since different browsers support different CSS selectors, it seems necessary to provide a way to indicate which selectors can actually be used by querySelector() and querySelectorAll(). Something along the lines of supportsSelector() that returns true if a certain type of selector is available and false if not, perhaps? Just to throw something out for a debate:

interface DocumentSelector {
  const unsigned short CHILD_SELECTOR = 1;
  const unsigned short DESCENDANT_SELECTOR = 2;
  const unsigned short ADJACENT_SELECTOR = 3;
  const unsigned short UNIVERSAL_SELECTOR = 4;
  const unsigned short TYPE_SELECTOR = 5;
  const unsigned short ATTRIBUTE_PRESENT_SELECTOR = 6;
  const unsigned short ATTRIBUTE_EQUALS_SELECTOR = 7;
  const unsigned short ATTRIBUTE_CONTAINS_HYPHEN_SELECTOR = 8;
  const unsigned short ATTRIBUTE_CONTAINS_SPACE_SELECTOR = 9;
  const unsigned short ID_SELECTOR = 10;
  const unsigned short AFTER_SELECTOR = 11;
 const unsigned short BEFORE_SELECTOR = 12;
 const unsigned short FIRST_CHILD_SELECTOR = 13;
 const unsigned short LAST_CHILD_SELECTOR = 14;
 const unsigned short LINK_SELECTOR = 15;
 const unsigned short HOVER_SELECTOR = 16;
 const unsigned short FOCUS_SELECTOR = 17;
 const unsigned short ACTIVE_SELECTOR = 18;
 const unsigned short LANG_SELECTOR = 19;
 const unsigned short FIRST_LINE_SELECTOR = 20;
 const unsigned short FIRST_LETTER_SELECTOR = 21;

  bool               supportsSelector(unsigned short selectorType);

  Element         querySelector(in DOMString selectors);
  Element         querySelector(in DOMString selectors, in NSResolver nsresolver);
  StaticNodeList  querySelectorAll(in DOMString selectors);
  StaticNodeList  querySelectorAll(in DOMString selectors, in NSResolver nsresolver);
};

Without this information, it's impossible to tell if a query returned no results because there were no elements matching the pattern or if the browser just didn't understand the selector being used.

-Nicholas




      ____________________________________________________________________________________
You rock. That's why Blockbuster's offering you one month of Blockbuster Total Access, No Cost.  
http://tc.deals.yahoo.com/tc/blockbuster/text5.com
Received on Sunday, 6 April 2008 08:36:46 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 27 April 2009 13:55:04 GMT