Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port css2xpath.js #10

Open
Kroc opened this issue Jul 16, 2012 · 6 comments
Open

Port css2xpath.js #10

Kroc opened this issue Jul 16, 2012 · 6 comments

Comments

@Kroc
Copy link
Owner

Kroc commented Jul 16, 2012

The plan is to support full CSS queries for queries as these are better known, easier for web developers to use and more natural to the content being worked with.

There's a compact JavaScript CSS to XPath converter here https://code.google.com/p/css2xpath/source/browse/trunk/src/css2xpath.js that I can port to PHP.

@Kroc
Copy link
Owner Author

Kroc commented Jul 25, 2012

One consideration that came to me last night was that if using CSS to select, there needs to be a way to select element attributes (something CSS can't intrinsically do), and that there would be a need to select and element based on it's attributes, but also select an attribute of that element. Will give this my consideration when I get to it.

@ghost
Copy link

ghost commented Jul 25, 2012

Eh? CSS has attribute selectors. I'm probably misunderstanding you.

@Kroc
Copy link
Owner Author

Kroc commented Jul 25, 2012

Yes, CSS has attribute selectors to select an element based upon an attribute, but it cannot select the attribute itself! You can't target the href in a href! :)

@ghost
Copy link

ghost commented Jul 25, 2012

Oh, right.

@iaindooley
Copy link

You don't really need to target an attribute do you? Once you've got the node you can just use getAttribute or setAttribute to work on it.

@Kroc
Copy link
Owner Author

Kroc commented Aug 18, 2012

Well, there's a need to do it in the CSS for the instance of automatically running a large number of 3rd-party queries through DOMTemplate -- i.e. the translation run in NNF. The translations are provided as a simple array of 'query' > 'string' and have the need to set attributes. The translation logic in NNF simply passes the whole array to DOMTemplate, it doesn't check which points to an attribute and which doesn't; and that would be a bad idea anyway as it would mean running the queries twice, or worse re-implementing parts of DOMTemplate within an NNF function.

IMO I should change the CSS attribute selector (without condition), i.e. e[attrib] to target the attribute itself. There shouldn't be much need to select an element only by the presence of an attribute; the dev can use the heirarchy or a class/ID. Alternatively I could add an @attrib extension to the CSS.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants