-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Conversation
$test = Css2Xpath::transform('a[href="http://example.com"]'); | ||
$this->assertEquals("//a[@href='http://example.com']", $test); | ||
|
||
$test = Css2Xpath::transform('a[@href="http://example.com"]'); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
I've added an additional test to QueryTest, I would imagine that this is the preferred result from the Dom/Query class. |
I was incorrect in my initial review of 5310, this class is meant to do more than just css selectors.