From d64e94e264677ef675e71b99b57cd9dda896161d Mon Sep 17 00:00:00 2001 From: "mariano.iglesias" Date: Wed, 16 Apr 2008 22:17:11 +0000 Subject: [PATCH] Fixing issue where AjaxHelper::link() would produce non-XHTML compliant links git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6677 3807eeeb-6ff5-0310-8944-8be069107fe0 --- cake/libs/view/helpers/ajax.php | 2 +- cake/tests/cases/libs/view/helpers/ajax.test.php | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/cake/libs/view/helpers/ajax.php b/cake/libs/view/helpers/ajax.php index dec030478..0c97838f7 100644 --- a/cake/libs/view/helpers/ajax.php +++ b/cake/libs/view/helpers/ajax.php @@ -186,7 +186,7 @@ class AjaxHelper extends AppHelper { $options['confirm'] = $confirm; unset($confirm); } - $htmlOptions = $this->__getHtmlOptions($options); + $htmlOptions = $this->__getHtmlOptions($options, array('url')); if (empty($options['fallback']) || !isset($options['fallback'])) { $options['fallback'] = $href; diff --git a/cake/tests/cases/libs/view/helpers/ajax.test.php b/cake/tests/cases/libs/view/helpers/ajax.test.php index 5c07bcfc0..7a90fd0c7 100644 --- a/cake/tests/cases/libs/view/helpers/ajax.test.php +++ b/cake/tests/cases/libs/view/helpers/ajax.test.php @@ -222,6 +222,7 @@ class AjaxTest extends UnitTestCase { $this->assertPattern('/^]+id="link\d+"[^<>]*>/', $result); $this->assertPattern('/^]+onclick="\s*event.returnValue = false;\s*return false;"[^<>]*>/', $result); $this->assertPattern('/]+type="text\/javascript"[^<>]*>/', $result); + $this->assertNoPattern('/^]*url="[^"]*"[^<>]*>/', $result); $this->assertNoPattern('/]+[^type]=[^<>]*>/', $result); $this->assertPattern('/Event.observe\(\'link\d+\',\s*\'click\',\s*function\(event\)\s*{.+},\s*false\);\s*' . str_replace('/', '\\/', preg_quote('//]]>')) . '\s*<\/script>$/', $result); $this->assertPattern('/function\(event\)\s*{\s*new Ajax\.Request\(\'http:\/\/www.cakephp.org\/downloads\',\s*{asynchronous:true, evalScripts:true}\)\s*},\s*false\);/', $result); @@ -232,6 +233,7 @@ class AjaxTest extends UnitTestCase { $this->assertPattern('/^]+id="link\d+"[^<>]*>/', $result); $this->assertPattern('/^]+onclick="\s*event.returnValue = false;\s*return false;"[^<>]*>/', $result); $this->assertPattern('/]+type="text\/javascript"[^<>]*>/', $result); + $this->assertNoPattern('/^]*url="[^"]*"[^<>]*>/', $result); $this->assertNoPattern('/]+[^type]=[^<>]*>/', $result); $this->assertPattern('/Event.observe\(\'link\d+\',\s*\'click\',\s*function\(event\)\s*{.+},\s*false\);\s*' . str_replace('/', '\\/', preg_quote('//]]>')) . '\s*<\/script>$/', $result); $this->assertPattern('/function\(event\)\s*{\s*if \(confirm\(\'Are you sure & positive\?\'\)\) {\s*new Ajax\.Request\(\'http:\/\/www.cakephp.org\/downloads\',\s*{asynchronous:true, evalScripts:true}\);\s*}\s*else\s*{\s*event.returnValue = false;\s*return false;\s*}\s*},\s*false\);/', $result); @@ -242,6 +244,7 @@ class AjaxTest extends UnitTestCase { $this->assertPattern('/^]+id="link\d+"[^<>]*>/', $result); $this->assertPattern('/^]+onclick="\s*event.returnValue = false;\s*return false;"[^<>]*>/', $result); $this->assertPattern('/]+type="text\/javascript"[^<>]*>/', $result); + $this->assertNoPattern('/^]*url="[^"]*"[^<>]*>/', $result); $this->assertNoPattern('/]+[^type]=[^<>]*>/', $result); $this->assertPattern('/Event.observe\(\'link\d+\',\s*\'click\',\s*function\(event\)\s*{.+},\s*false\);\s*' . str_replace('/', '\\/', preg_quote('//]]>')) . '\s*<\/script>$/', $result); $this->assertPattern('/function\(event\)\s*{\s*new Ajax\.Updater\(\'myDiv\',\s*\'http:\/\/www.cakephp.org\/downloads\',\s*{asynchronous:true, evalScripts:true, requestHeaders:\[\'X-Update\', \'myDiv\'\]}\)\s*},\s*false\);/', $result); @@ -252,6 +255,7 @@ class AjaxTest extends UnitTestCase { $this->assertPattern('/^]+id="myLink"[^<>]*>/', $result); $this->assertPattern('/^]+onclick="\s*event.returnValue = false;\s*return false;"[^<>]*>/', $result); $this->assertPattern('/]+type="text\/javascript"[^<>]*>/', $result); + $this->assertNoPattern('/^]*url="[^"]*"[^<>]*>/', $result); $this->assertNoPattern('/]+[^type]=[^<>]*>/', $result); $this->assertPattern('/Event.observe\(\'myLink\',\s*\'click\',\s*function\(event\)\s*{.+},\s*false\);\s*' . str_replace('/', '\\/', preg_quote('//]]>')) . '\s*<\/script>$/', $result); $this->assertPattern('/function\(event\)\s*{\s*new Ajax\.Updater\(\'myDiv\',\s*\'http:\/\/www.cakephp.org\/downloads\',\s*{asynchronous:true, evalScripts:true, requestHeaders:\[\'X-Update\', \'myDiv\'\]}\)\s*},\s*false\);/', $result); @@ -262,6 +266,7 @@ class AjaxTest extends UnitTestCase { $this->assertPattern('/^]+id="myLink"[^<>]*>/', $result); $this->assertPattern('/^]+onclick="\s*event.returnValue = false;\s*return false;"[^<>]*>/', $result); $this->assertPattern('/]+type="text\/javascript"[^<>]*>/', $result); + $this->assertNoPattern('/^]*url="[^"]*"[^<>]*>/', $result); $this->assertNoPattern('/]+[^type]=[^<>]*>/', $result); $this->assertPattern('/Event.observe\(\'myLink\',\s*\'click\',\s*function\(event\)\s*{.+},\s*false\);\s*' . str_replace('/', '\\/', preg_quote('//]]>')) . '\s*<\/script>$/', $result); $this->assertPattern('/function\(event\)\s*{\s*new Ajax\.Updater\(\'myDiv\',\s*\'http:\/\/www.cakephp.org\/downloads\',\s*{asynchronous:true, evalScripts:true, onComplete:function\(request, json\) {myComplete\(\);}, requestHeaders:\[\'X-Update\', \'myDiv\'\]}\)\s*},\s*false\);/', $result); @@ -272,6 +277,7 @@ class AjaxTest extends UnitTestCase { $this->assertPattern('/^]+id="myLink"[^<>]*>/', $result); $this->assertPattern('/^]+onclick="\s*event.returnValue = false;\s*return false;"[^<>]*>/', $result); $this->assertPattern('/]+type="text\/javascript"[^<>]*>/', $result); + $this->assertNoPattern('/^]*url="[^"]*"[^<>]*>/', $result); $this->assertNoPattern('/]+[^type]=[^<>]*>/', $result); $this->assertPattern('/Event.observe\(\'myLink\',\s*\'click\',\s*function\(event\)\s*{.+},\s*false\);\s*' . str_replace('/', '\\/', preg_quote('//]]>')) . '\s*<\/script>$/', $result); $this->assertPattern('/function\(event\)\s*{\s*new Ajax\.Updater\(\'myDiv\',\s*\'http:\/\/www.cakephp.org\/downloads\',\s*{asynchronous:true, evalScripts:true, onComplete:function\(request, json\) {myComplete\(\);}, onLoading:function\(request\) {myLoading\(\);}, requestHeaders:\[\'X-Update\', \'myDiv\'\]}\)\s*},\s*false\);/', $result); @@ -281,6 +287,7 @@ class AjaxTest extends UnitTestCase { $this->assertPattern('/^]+href="http:\/\/www.cakephp.org\/downloads"[^<>]*>/', $result); $this->assertPattern('/^]+onclick="\s*event.returnValue = false;\s*return false;"[^<>]*>/', $result); $this->assertPattern('/]+type="text\/javascript"[^<>]*>/', $result); + $this->assertNoPattern('/^]*url="[^"]*"[^<>]*>/', $result); $this->assertNoPattern('/]+[^type]=[^<>]*>/', $result); $this->assertPattern('/Event.observe\(\'\w+\',\s*\'click\',\s*function\(event\)\s*{.+},\s*false\);\s*' . str_replace('/', '\\/', preg_quote('//]]>')) . '\s*<\/script>$/', $result); $this->assertPattern('/function\(event\)\s*{\s*new Ajax\.Updater\(\'myDiv\',\s*\'http:\/\/www.cakephp.org\/downloads\',\s*{asynchronous:true, evalScripts:true, encoding:\'utf-8\', requestHeaders:\[\'X-Update\', \'myDiv\'\]}\)\s*},\s*false\);/', $result); @@ -290,6 +297,7 @@ class AjaxTest extends UnitTestCase { $this->assertPattern('/^]+href="http:\/\/www.cakephp.org\/downloads"[^<>]*>/', $result); $this->assertPattern('/^]+onclick="\s*event.returnValue = false;\s*return false;"[^<>]*>/', $result); $this->assertPattern('/]+type="text\/javascript"[^<>]*>/', $result); + $this->assertNoPattern('/^]*url="[^"]*"[^<>]*>/', $result); $this->assertNoPattern('/]+[^type]=[^<>]*>/', $result); $this->assertPattern('/Event.observe\(\'\w+\',\s*\'click\',\s*function\(event\)\s*{.+},\s*false\);\s*' . str_replace('/', '\\/', preg_quote('//]]>')) . '\s*<\/script>$/', $result); $this->assertPattern('/function\(event\)\s*{\s*new Ajax\.Updater\(\'myDiv\',\s*\'http:\/\/www.cakephp.org\/downloads\',\s*{asynchronous:true, evalScripts:true, onSuccess:function\(request\) {success\(\);}, requestHeaders:\[\'X-Update\', \'myDiv\'\]}\)\s*},\s*false\);/', $result); @@ -299,6 +307,7 @@ class AjaxTest extends UnitTestCase { $this->assertPattern('/^]+href="http:\/\/www.cakephp.org\/downloads"[^<>]*>/', $result); $this->assertPattern('/^]+onclick="\s*event.returnValue = false;\s*return false;"[^<>]*>/', $result); $this->assertPattern('/]+type="text\/javascript"[^<>]*>/', $result); + $this->assertNoPattern('/^]*url="[^"]*"[^<>]*>/', $result); $this->assertNoPattern('/]+[^type]=[^<>]*>/', $result); $this->assertPattern('/Event.observe\(\'\w+\',\s*\'click\',\s*function\(event\)\s*{.+},\s*false\);\s*' . str_replace('/', '\\/', preg_quote('//]]>')) . '\s*<\/script>$/', $result); $this->assertPattern('/function\(event\)\s*{\s*new Ajax\.Updater\(\'myDiv\',\s*\'http:\/\/www.cakephp.org\/downloads\',\s*{asynchronous:true, evalScripts:true, onFailure:function\(request\) {failure\(\);}, requestHeaders:\[\'X-Update\', \'myDiv\'\]}\)\s*},\s*false\);/', $result); @@ -307,6 +316,7 @@ class AjaxTest extends UnitTestCase { $this->assertPattern('/^]+>Ajax Link<\/a>