Author: bschussek Date: 2010-04-15 10:33:58 +0200 (Thu, 15 Apr 2010) New Revision: 29158
Modified: branches/1.3/lib/util/sfDomCssSelector.class.php branches/1.3/test/unit/util/sfDomCssSelectorTest.php branches/1.4/lib/util/sfDomCssSelector.class.php branches/1.4/test/unit/util/sfDomCssSelectorTest.php Log: [1.3, 1.4] fixed sfDomCssSelector when selecting by attributes evaluating to false (closes #8120) Modified: branches/1.3/lib/util/sfDomCssSelector.class.php =================================================================== --- branches/1.3/lib/util/sfDomCssSelector.class.php 2010-04-15 03:55:30 UTC (rev 29157) +++ branches/1.3/lib/util/sfDomCssSelector.class.php 2010-04-15 08:33:58 UTC (rev 29158) @@ -3,7 +3,7 @@ /* * This file is part of the symfony package. * (c) 2004-2006 Fabien Potencier <[email protected]> - * + * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ @@ -198,7 +198,7 @@ { $attrName = $match[1]; $attrOperator = $match[2]; - $attrValue = $match[4] ? $match[4] : $match[5]; + $attrValue = $match[4] === '' ? $match[5] : $match[4]; switch ($attrOperator) { Modified: branches/1.3/test/unit/util/sfDomCssSelectorTest.php =================================================================== --- branches/1.3/test/unit/util/sfDomCssSelectorTest.php 2010-04-15 03:55:30 UTC (rev 29157) +++ branches/1.3/test/unit/util/sfDomCssSelectorTest.php 2010-04-15 08:33:58 UTC (rev 29158) @@ -3,14 +3,14 @@ /* * This file is part of the symfony package. * (c) 2004-2006 Fabien Potencier <[email protected]> - * + * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ require_once(dirname(__FILE__).'/../../bootstrap/unit.php'); -$t = new lime_test(70); +$t = new lime_test(71); $html = <<<EOF <html> @@ -27,6 +27,10 @@ <p onclick="javascript:alert('with a . and a # inside an attribute');">works great</p> + <select> + <option value="0">foo input</option> + </select> + <div id="simplelist"> <ul id="list"> <li>First</li> @@ -90,6 +94,7 @@ $t->is($c->matchAll('div#footer')->getValues(), array('footer'), '->matchAll() supports searching html elements by id for a tag name'); $t->is($c->matchAll('*[class="myfoo"]')->getValues(), array('myfoo', 'myfoo bis'), '->matchAll() can take a * to match every elements'); $t->is($c->matchAll('*[class=myfoo]')->getValues(), array('myfoo', 'myfoo bis'), '->matchAll() can take a * to match every elements'); +$t->is($c->matchAll('*[value="0"]')->getValues(), array('foo input'), '->matchAll() can take a * to match every elements'); $t->is($c->matchAll('.header')->getValues(), array('header'), '->matchAll() supports searching html elements by class name'); $t->is($c->matchAll('p.header')->getValues(), array('header'), '->matchAll() supports searching html elements by class name for a tag name'); Modified: branches/1.4/lib/util/sfDomCssSelector.class.php =================================================================== --- branches/1.4/lib/util/sfDomCssSelector.class.php 2010-04-15 03:55:30 UTC (rev 29157) +++ branches/1.4/lib/util/sfDomCssSelector.class.php 2010-04-15 08:33:58 UTC (rev 29158) @@ -3,7 +3,7 @@ /* * This file is part of the symfony package. * (c) 2004-2006 Fabien Potencier <[email protected]> - * + * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ @@ -185,7 +185,7 @@ { $attrName = $match[1]; $attrOperator = $match[2]; - $attrValue = $match[4] ? $match[4] : $match[5]; + $attrValue = $match[4] === '' ? $match[5] : $match[4]; switch ($attrOperator) { Modified: branches/1.4/test/unit/util/sfDomCssSelectorTest.php =================================================================== --- branches/1.4/test/unit/util/sfDomCssSelectorTest.php 2010-04-15 03:55:30 UTC (rev 29157) +++ branches/1.4/test/unit/util/sfDomCssSelectorTest.php 2010-04-15 08:33:58 UTC (rev 29158) @@ -3,14 +3,14 @@ /* * This file is part of the symfony package. * (c) 2004-2006 Fabien Potencier <[email protected]> - * + * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ require_once(dirname(__FILE__).'/../../bootstrap/unit.php'); -$t = new lime_test(70); +$t = new lime_test(71); $html = <<<EOF <html> @@ -27,6 +27,10 @@ <p onclick="javascript:alert('with a . and a # inside an attribute');">works great</p> + <select> + <option value="0">foo input</option> + </select> + <div id="simplelist"> <ul id="list"> <li>First</li> @@ -90,6 +94,7 @@ $t->is($c->matchAll('div#footer')->getValues(), array('footer'), '->matchAll() supports searching html elements by id for a tag name'); $t->is($c->matchAll('*[class="myfoo"]')->getValues(), array('myfoo', 'myfoo bis'), '->matchAll() can take a * to match every elements'); $t->is($c->matchAll('*[class=myfoo]')->getValues(), array('myfoo', 'myfoo bis'), '->matchAll() can take a * to match every elements'); +$t->is($c->matchAll('*[value="0"]')->getValues(), array('foo input'), '->matchAll() can take a * to match every elements'); $t->is($c->matchAll('.header')->getValues(), array('header'), '->matchAll() supports searching html elements by class name'); $t->is($c->matchAll('p.header')->getValues(), array('header'), '->matchAll() supports searching html elements by class name for a tag name'); -- You received this message because you are subscribed to the Google Groups "symfony SVN" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/symfony-svn?hl=en.
