You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
.Parents(string) accepts a filter and it should accept a selector #18
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)
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 :)
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.
Activity
jamietre commentedon Jul 10, 2012
Is something not working? This is part of the CsQuery API already, here's the sig:
allroadcole commentedon Jul 10, 2012
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:
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 :)
jamietre commentedon Jul 10, 2012
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 affectsstyle. 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.
allroadcole commentedon Jul 10, 2012
awesome, thanks!
Fix for Issue #18: attribute selector not working for class/style
jamietre commentedon Jul 10, 2012
Pushed now, let me know if it works for you.
allroadcole commentedon Jul 10, 2012
It works!
Thanks.