diff --git a/cake/libs/view/helpers/javascript.php b/cake/libs/view/helpers/javascript.php index 3e07ef9bd..ec66579aa 100644 --- a/cake/libs/view/helpers/javascript.php +++ b/cake/libs/view/helpers/javascript.php @@ -632,7 +632,10 @@ class JavascriptHelper extends AppHelper { foreach ($data as $key => $val) { if (is_array($val) || is_object($val)) { - $val = $this->object($val, array_merge($options, array('block' => false))); + $val = $this->object( + $val, + array_merge($options, array('block' => false, 'prefix' => '', 'postfix' => '')) + ); } else { $quoteStrings = ( !count($options['stringKeys']) || diff --git a/cake/tests/cases/libs/view/helpers/javascript.test.php b/cake/tests/cases/libs/view/helpers/javascript.test.php index e9bffea7a..83c1b74d0 100644 --- a/cake/tests/cases/libs/view/helpers/javascript.test.php +++ b/cake/tests/cases/libs/view/helpers/javascript.test.php @@ -392,6 +392,13 @@ class JavascriptTest extends CakeTestCase { $result = $this->Javascript->object($data); $this->assertEqual($result, $expected); } + + $object = array('title' => 'New thing', 'indexes' => array(5, 6, 7, 8), 'object' => array('inner' => array('value' => 1))); + $result = $this->Javascript->object($object, array('prefix' => 'PREFIX', 'postfix' => 'POSTFIX')); + $this->assertPattern('/^PREFIX/', $result); + $this->assertPattern('/POSTFIX$/', $result); + $this->assertNoPattern('/.PREFIX./', $result); + $this->assertNoPattern('/.POSTFIX./', $result); if ($this->Javascript->useNative) { $this->Javascript->useNative = false;