<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://www.w3.org/Bugs/Public/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4"
          urlbase="https://www.w3.org/Bugs/Public/"
          
          maintainer="sysbot+bugzilla@w3.org"
>

    <bug>
          <bug_id>5865</bug_id>
          
          <creation_ts>2008-07-14 08:31:23 +0000</creation_ts>
          <short_desc>[selectors-api2] Add method to check if a given element matches a selector</short_desc>
          <delta_ts>2009-09-26 21:49:34 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebAppsWG</product>
          <component>HISTORICAL - Selectors API</component>
          <version>unspecified</version>
          <rep_platform>PC</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>enhancement</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Lachlan Hunt">lachlan.hunt</reporter>
          <assigned_to name="Lachlan Hunt">lachlan.hunt</assigned_to>
          <cc>jresig</cc>
    
    <cc>lachlan.hunt</cc>
    
    <cc>mike</cc>
          
          <qa_contact>public-webapps-bugzilla</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>21170</commentid>
    <comment_count>0</comment_count>
    <who name="Lachlan Hunt">lachlan.hunt</who>
    <bug_when>2008-07-14 08:31:23 +0000</bug_when>
    <thetext>There has been some suggestions to introduce a new Element.matchesSelector() method.

http://lists.w3.org/Archives/Public/public-webapi/2007Jan/0183.html
http://lists.w3.org/Archives/Public/public-webapi/2008Apr/0128.html
http://lists.w3.org/Archives/Public/www-style/2008Jul/0291.html

Need to investigate use cases.

Could possibly work something like this:

foo.matchesSelector(&quot;section&gt;p&quot;);
foo.matchesSelector(&quot;h1+:context&quot;);

Returns boolean.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>22704</commentid>
    <comment_count>1</comment_count>
    <who name="Lachlan Hunt">lachlan.hunt</who>
    <bug_when>2008-12-08 08:44:55 +0000</bug_when>
    <thetext>More discussion of this proposal:

http://lists.w3.org/Archives/Public/public-webapps/2008OctDec/0433.html
http://lists.w3.org/Archives/Public/public-webapps/2008OctDec/0435.html
http://lists.w3.org/Archives/Public/public-webapps/2008OctDec/0439.html
http://lists.w3.org/Archives/Public/public-webapps/2008OctDec/0442.html
http://lists.w3.org/Archives/Public/public-webapps/2008OctDec/0447.html</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>22708</commentid>
    <comment_count>2</comment_count>
    <who name="Lachlan Hunt">lachlan.hunt</who>
    <bug_when>2008-12-08 15:08:57 +0000</bug_when>
    <thetext>JQuery implementation
http://docs.jquery.com/Traversing/is#expr</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>27561</commentid>
    <comment_count>3</comment_count>
    <who name="Lachlan Hunt">lachlan.hunt</who>
    <bug_when>2009-09-22 17:14:21 +0000</bug_when>
    <thetext>Mozilla have begun work on an implementation
https://bugzilla.mozilla.org/show_bug.cgi?id=518003</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>27562</commentid>
    <comment_count>4</comment_count>
    <who name="John Resig">jresig</who>
    <bug_when>2009-09-22 17:46:22 +0000</bug_when>
    <thetext>Test Suite can be found here:
http://github.com/jeresig/selectortest/tree/matchesSelector</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>27639</commentid>
    <comment_count>5</comment_count>
    <who name="Lachlan Hunt">lachlan.hunt</who>
    <bug_when>2009-09-24 12:25:07 +0000</bug_when>
    <thetext>Use Case: Event Delegation

Listening to events on occurring on many elements is made easier by event bubbling, and listening for the event on a common ancestor element of those you want to listen for.  This is commonly done on the body element.  The technique relies on the ability to check which element or type of element the event target is.

Having a function to check if the event target matches a particular selector makes this easier than having to manually check several different properties of the element.

For example, executing some function of the event handler may depend on the element being an input element that is a checkbox and has is checked (i.e. matches the selector &quot;input[type=checkbox]:checked&quot;. Checking each of these propertie separately in order to determine how to handle the event is more complicated.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>27652</commentid>
    <comment_count>6</comment_count>
    <who name="Lachlan Hunt">lachlan.hunt</who>
    <bug_when>2009-09-24 22:16:29 +0000</bug_when>
    <thetext>WebKit implementation.
https://bugs.webkit.org/show_bug.cgi?id=29703</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>27687</commentid>
    <comment_count>7</comment_count>
    <who name="Lachlan Hunt">lachlan.hunt</who>
    <bug_when>2009-09-26 21:49:34 +0000</bug_when>
    <thetext>matchesSelector() is now defined.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>