Skip to content

.Parents(string) accepts a filter and it should accept a selector #18

Closed

Activity

  1. jamietre commented on Jul 10, 2012

    @jamietre
    Owner

    Is something not working? This is part of the CsQuery API already, here's the sig:

        /// <summary>
        /// Get the ancestors of each element in the current set of matched elements, optionally filtered
        /// by a selector.
        /// </summary>
        ///
        /// <param name="filter">
        /// (optional) a selector which limits the elements returned.
        /// </param>
        ///
        /// <returns>
        /// A new CQ object.
        /// </returns>
        ///
        /// <url>
        /// http://api.jquery.com/parents/
        /// </url>
    
        public CQ Parents(string filter = null)
    
  2. allroadcole commented on Jul 10, 2012

    @allroadcole
    Author

    wow, thanks for the instant response.

    Yeah, I'm not getting results back from CQ Parents() like I do with JQ parents().

    I just noticed that it does work with class selectors, just not attribute selectors.

    For example, this is from the watch window in Visual Studio:

    cq.Parent() = {<div class="skip-link">...</div>}
    
    cq.Parents(".skip-link") =  {<div class="skip-link">...</div>}
    
    cq.Parents("[class='skip-link']") =  {}
    

    This is a simplified example that I was just using for testing. I do need to use Parents with an attribute selector though.

    When I test the same element using JQ in the browser I get results back from jq.parents("[class='skip-link']")

    I put a break point in CsQuery.Engine.AttributeSelectors.MatchesAttribute to try and debug why it was not matching, but it never gets hit. I have not looked in to it much past that yet...

    Let me know what you think.

    Thanks again!

    BTW, CQ is a great project, I plan to use it a lot :)

  3. jamietre commented on Jul 10, 2012

    @jamietre
    Owner

    Wow... I literally (as in fifteen minutes ago) just fixed this bug. It's not specific to Parents() but to class-as-attribute selectors, and also affects style. It's because they are not treated the same as other attributes internally and there is a special case for adding them to the index. I must have broken this a few weeks ago when I made some performance improvements to attribute handling, apparently never had tests specifically for style or class as attributes!

    Anyway - will push an update in a few minutes, I'm almost ready to push a nuget update as well (there's a significant new feature in the current code, the pseudo-class selectors have been abstracted and there's an API to add user-defined ones) but maybe not till tonight or tomorrow. In the mean time you can grab the latest from here, should be up in a few minutes.

  4. allroadcole commented on Jul 10, 2012

    @allroadcole
    Author

    awesome, thanks!

  5. added a commit that references this issue on Jul 10, 2012
  6. jamietre commented on Jul 10, 2012

    @jamietre
    Owner

    Pushed now, let me know if it works for you.

  7. allroadcole commented on Jul 10, 2012

    @allroadcole
    Author

    It works!

    Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions