Skip to content
This repository has been archived by the owner on Jan 8, 2020. It is now read-only.

fixes #5310 #5351

Closed
wants to merge 3 commits into from
Closed

Conversation

steverhoades
Copy link
Contributor

I was incorrect in my initial review of 5310, this class is meant to do more than just css selectors.

$test = Css2Xpath::transform('a[href="http://example.com"]');
$this->assertEquals("//a[@href='http://example.com']", $test);

$test = Css2Xpath::transform('a[@href="http://example.com"]');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this throw a exception since @ is not a valid CSS selector?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Maks3w Thats a great question, the fact is, the function converts the code to include the @ symbol, I think it would be weird to throw an exception if one includes the @ symbol, seeing as the result of the function outputs the correctly formatted query.

EDIT: to clarify above

$test = Css2Xpath::transform('a[href="http://example.com"]');
echo $test; // outputs: //a[@href='http://example.com']

The reason I included that test was to ensure that when an @ was included that the double quotes were converted to a single quote, so the 2 were consistent. It does seem odd to me that the CSS2XPath is modifying this query in general, and perhaps that is the modification that needs to be made in this regard, IE> ignore attributes? Unfortunately I don't know enough of the history of this class to make that decision.

@steverhoades
Copy link
Contributor Author

I've added an additional test to QueryTest, I would imagine that this is the preferred result from the Dom/Query class.

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

Successfully merging this pull request may close these issues.

3 participants