mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
Fixing incorrect setting of default value for 'onDomReady' option in JsHelper::writeBuffer()
This commit is contained in:
parent
73aeb6ba62
commit
df097796c4
2 changed files with 12 additions and 2 deletions
|
@ -302,10 +302,20 @@ class JsHelperTest extends CakeTestCase {
|
|||
*/
|
||||
public function testWriteBufferAndXhr() {
|
||||
$this->_useMock();
|
||||
$this->Js->params['isAjax'] = true;
|
||||
$requestWith = null;
|
||||
if (isset($_SERVER['HTTP_X_REQUESTED_WITH'])) {
|
||||
$requestWith = $_SERVER['HTTP_X_REQUESTED_WITH'];
|
||||
}
|
||||
$_SERVER['HTTP_X_REQUESTED_WITH'] = 'XMLHttpRequest';
|
||||
|
||||
$this->Js->buffer('alert("test");');
|
||||
$this->Js->TestJsEngine->expects($this->never())->method('domReady');
|
||||
$result = $this->Js->writeBuffer();
|
||||
|
||||
unset($_SERVER['HTTP_X_REQUESTED_WITH']);
|
||||
if ($requestWith !== null) {
|
||||
$_SERVER['HTTP_X_REQUESTED_WITH'] = $requestWith;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -190,7 +190,7 @@ class JsHelper extends AppHelper {
|
|||
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/js.html#JsHelper::writeBuffer
|
||||
*/
|
||||
public function writeBuffer($options = array()) {
|
||||
$domReady = $this->request->is('ajax');
|
||||
$domReady = !$this->request->is('ajax');
|
||||
$defaults = array(
|
||||
'onDomReady' => $domReady, 'inline' => true,
|
||||
'cache' => false, 'clear' => true, 'safe' => true
|
||||
|
|
Loading…
Reference in a new issue