Permalink
Browse files

Remove type attributes from script and link tags.

They are optional in HTML5 which is going to be the default doctype for
3.0
  • Loading branch information...
1 parent 4eb4335 commit 5c49e139f1d94cd0c24555a41975b8216b4f6cc8 @markstory markstory committed Mar 8, 2014
Showing with 41 additions and 42 deletions.
  1. +3 −3 src/View/Helper/HtmlHelper.php
  2. +38 −39 tests/TestCase/View/Helper/HtmlHelperTest.php
@@ -101,15 +101,15 @@ class HtmlHelper extends Helper {
'tagselfclosing' => '<{{tag}}{{attrs}}/>',
'para' => '<p{{attrs}}>{{content}}</p>',
'parastart' => '<p{{attrs}}>',
- 'css' => '<link rel="{{rel}}" type="text/css" href="{{url}}"{{attrs}}/>',
+ 'css' => '<link rel="{{rel}}" href="{{url}}"{{attrs}}/>',
'style' => '<style type="text/css"{{attrs}}>{{content}}</style>',
'charset' => '<meta http-equiv="Content-Type" content="text/html; charset={{charset}}" />',
'ul' => '<ul{{attrs}}>{{content}}</ul>',
'ol' => '<ol{{attrs}}>{{content}}</ol>',
'li' => '<li{{attrs}}>{{content}}</li>',
'javascriptblock' => '<script{{attrs}}>{{content}}</script>',
'javascriptstart' => '<script>',
- 'javascriptlink' => '<script type="text/javascript" src="{{url}}"{{attrs}}></script>',
+ 'javascriptlink' => '<script src="{{url}}"{{attrs}}></script>',
'javascriptend' => '</script>'
];
@@ -585,7 +585,7 @@ public function script($url, $options = array()) {
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/html.html#HtmlHelper::scriptBlock
*/
public function scriptBlock($script, $options = array()) {
- $options += array('type' => 'text/javascript', 'safe' => true, 'inline' => true);
+ $options += array('safe' => true, 'inline' => true);
if ($options['safe']) {
$script = "\n" . '//<![CDATA[' . "\n" . $script . "\n" . '//]]>' . "\n";
}
@@ -474,14 +474,14 @@ public function testThemeAssetsInMainWebrootPath() {
$this->Html->theme = 'test_theme';
$result = $this->Html->css('webroot_test');
$expected = array(
- 'link' => array('rel' => 'stylesheet', 'type' => 'text/css', 'href' => 'preg:/.*theme\/test_theme\/css\/webroot_test\.css/')
+ 'link' => array('rel' => 'stylesheet', 'href' => 'preg:/.*theme\/test_theme\/css\/webroot_test\.css/')
);
$this->assertTags($result, $expected);
$this->Html->theme = 'test_theme';
$result = $this->Html->css('theme_webroot');
$expected = array(
- 'link' => array('rel' => 'stylesheet', 'type' => 'text/css', 'href' => 'preg:/.*theme\/test_theme\/css\/theme_webroot\.css/')
+ 'link' => array('rel' => 'stylesheet', 'href' => 'preg:/.*theme\/test_theme\/css\/theme_webroot\.css/')
);
$this->assertTags($result, $expected);
}
@@ -513,7 +513,7 @@ public function testStyle() {
public function testCssLink() {
$result = $this->Html->css('screen');
$expected = array(
- 'link' => array('rel' => 'stylesheet', 'type' => 'text/css', 'href' => 'preg:/.*css\/screen\.css/')
+ 'link' => array('rel' => 'stylesheet', 'href' => 'preg:/.*css\/screen\.css/')
);
$this->assertTags($result, $expected);
@@ -594,7 +594,6 @@ public function testCssLinkBC() {
$expected = array(
'link' => array(
'rel' => 'stylesheet',
- 'type' => 'text/css',
'href' => 'preg:/.*css\/TestPlugin\.style\.css/'
)
);
@@ -627,7 +626,7 @@ public function testCssWithFullBase() {
$result = $this->Html->css('screen', null, array('fullBase' => true));
$expected = array(
- 'link' => array('rel' => 'stylesheet', 'type' => 'text/css', 'href' => $here . 'css/screen.css')
+ 'link' => array('rel' => 'stylesheet', 'href' => $here . 'css/screen.css')
);
$this->assertTags($result, $expected);
}
@@ -642,7 +641,7 @@ public function testPluginCssLink() {
$result = $this->Html->css('TestPlugin.test_plugin_asset');
$expected = array(
- 'link' => array('rel' => 'stylesheet', 'type' => 'text/css', 'href' => 'preg:/.*test_plugin\/css\/test_plugin_asset\.css/')
+ 'link' => array('rel' => 'stylesheet', 'href' => 'preg:/.*test_plugin\/css\/test_plugin_asset\.css/')
);
$this->assertTags($result, $expected);
@@ -677,7 +676,7 @@ public function testCssTimestamping() {
Configure::write('Asset.timestamp', true);
$expected = array(
- 'link' => array('rel' => 'stylesheet', 'type' => 'text/css', 'href' => '')
+ 'link' => array('rel' => 'stylesheet', 'href' => '')
);
$result = $this->Html->css('cake.generic');
@@ -719,7 +718,7 @@ public function testPluginCssTimestamping() {
Configure::write('Asset.timestamp', true);
$expected = array(
- 'link' => array('rel' => 'stylesheet', 'type' => 'text/css', 'href' => '')
+ 'link' => array('rel' => 'stylesheet', 'href' => '')
);
$result = $this->Html->css('TestPlugin.test_plugin_asset');
@@ -816,72 +815,72 @@ public function testPluginScriptTimestamping() {
public function testScript() {
$result = $this->Html->script('foo');
$expected = array(
- 'script' => array('type' => 'text/javascript', 'src' => 'js/foo.js')
+ 'script' => array('src' => 'js/foo.js')
);
$this->assertTags($result, $expected);
$result = $this->Html->script(array('foobar', 'bar'));
$expected = array(
- array('script' => array('type' => 'text/javascript', 'src' => 'js/foobar.js')),
+ array('script' => array('src' => 'js/foobar.js')),
'/script',
- array('script' => array('type' => 'text/javascript', 'src' => 'js/bar.js')),
+ array('script' => array('src' => 'js/bar.js')),
'/script',
);
$this->assertTags($result, $expected);
$result = $this->Html->script('jquery-1.3');
$expected = array(
- 'script' => array('type' => 'text/javascript', 'src' => 'js/jquery-1.3.js')
+ 'script' => array('src' => 'js/jquery-1.3.js')
);
$this->assertTags($result, $expected);
$result = $this->Html->script('test.json');
$expected = array(
- 'script' => array('type' => 'text/javascript', 'src' => 'js/test.json.js')
+ 'script' => array('src' => 'js/test.json.js')
);
$this->assertTags($result, $expected);
$result = $this->Html->script('http://example.com/test.json');
$expected = array(
- 'script' => array('type' => 'text/javascript', 'src' => 'http://example.com/test.json')
+ 'script' => array('src' => 'http://example.com/test.json')
);
$this->assertTags($result, $expected);
$result = $this->Html->script('/plugin/js/jquery-1.3.2.js?someparam=foo');
$expected = array(
- 'script' => array('type' => 'text/javascript', 'src' => '/plugin/js/jquery-1.3.2.js?someparam=foo')
+ 'script' => array('src' => '/plugin/js/jquery-1.3.2.js?someparam=foo')
);
$this->assertTags($result, $expected);
$result = $this->Html->script('test.json.js?foo=bar');
$expected = array(
- 'script' => array('type' => 'text/javascript', 'src' => 'js/test.json.js?foo=bar')
+ 'script' => array('src' => 'js/test.json.js?foo=bar')
);
$this->assertTags($result, $expected);
$result = $this->Html->script('test.json.js?foo=bar&other=test');
$expected = array(
- 'script' => array('type' => 'text/javascript', 'src' => 'js/test.json.js?foo=bar&amp;other=test')
+ 'script' => array('src' => 'js/test.json.js?foo=bar&amp;other=test')
);
$this->assertTags($result, $expected);
$result = $this->Html->script('foo2', array('pathPrefix' => '/my/custom/path/'));
$expected = array(
- 'script' => array('type' => 'text/javascript', 'src' => '/my/custom/path/foo2.js')
+ 'script' => array('src' => '/my/custom/path/foo2.js')
);
$this->assertTags($result, $expected);
$result = $this->Html->script('foo3', array('pathPrefix' => 'http://cakephp.org/assets/js/'));
$expected = array(
- 'script' => array('type' => 'text/javascript', 'src' => 'http://cakephp.org/assets/js/foo3.js')
+ 'script' => array('src' => 'http://cakephp.org/assets/js/foo3.js')
);
$this->assertTags($result, $expected);
$previousConfig = Configure::read('App.jsBaseUrl');
Configure::write('App.jsBaseUrl', '//cdn.cakephp.org/js/');
$result = $this->Html->script('foo4');
$expected = array(
- 'script' => array('type' => 'text/javascript', 'src' => '//cdn.cakephp.org/js/foo4.js')
+ 'script' => array('src' => '//cdn.cakephp.org/js/foo4.js')
);
$this->assertTags($result, $expected);
Configure::write('App.jsBaseUrl', $previousConfig);
@@ -897,7 +896,7 @@ public function testScript() {
$result = $this->Html->script('jquery-1.3.2', array('defer' => true, 'encoding' => 'utf-8'));
$expected = array(
- 'script' => array('type' => 'text/javascript', 'src' => 'js/jquery-1.3.2.js', 'defer' => 'defer', 'encoding' => 'utf-8')
+ 'script' => array('src' => 'js/jquery-1.3.2.js', 'defer' => 'defer', 'encoding' => 'utf-8')
);
$this->assertTags($result, $expected);
}
@@ -913,40 +912,40 @@ public function testPluginScript() {
$result = $this->Html->script('TestPlugin.foo');
$expected = array(
- 'script' => array('type' => 'text/javascript', 'src' => 'test_plugin/js/foo.js')
+ 'script' => array('src' => 'test_plugin/js/foo.js')
);
$this->assertTags($result, $expected);
$result = $this->Html->script(array('TestPlugin.foobar', 'TestPlugin.bar'));
$expected = array(
- array('script' => array('type' => 'text/javascript', 'src' => 'test_plugin/js/foobar.js')),
+ array('script' => array('src' => 'test_plugin/js/foobar.js')),
'/script',
- array('script' => array('type' => 'text/javascript', 'src' => 'test_plugin/js/bar.js')),
+ array('script' => array('src' => 'test_plugin/js/bar.js')),
'/script',
);
$this->assertTags($result, $expected);
$result = $this->Html->script('TestPlugin.jquery-1.3');
$expected = array(
- 'script' => array('type' => 'text/javascript', 'src' => 'test_plugin/js/jquery-1.3.js')
+ 'script' => array('src' => 'test_plugin/js/jquery-1.3.js')
);
$this->assertTags($result, $expected);
$result = $this->Html->script('TestPlugin.test.json');
$expected = array(
- 'script' => array('type' => 'text/javascript', 'src' => 'test_plugin/js/test.json.js')
+ 'script' => array('src' => 'test_plugin/js/test.json.js')
);
$this->assertTags($result, $expected);
$result = $this->Html->script('TestPlugin./jquery-1.3.2.js?someparam=foo');
$expected = array(
- 'script' => array('type' => 'text/javascript', 'src' => 'test_plugin/jquery-1.3.2.js?someparam=foo')
+ 'script' => array('src' => 'test_plugin/jquery-1.3.2.js?someparam=foo')
);
$this->assertTags($result, $expected);
$result = $this->Html->script('TestPlugin.test.json.js?foo=bar');
$expected = array(
- 'script' => array('type' => 'text/javascript', 'src' => 'test_plugin/js/test.json.js?foo=bar')
+ 'script' => array('src' => 'test_plugin/js/test.json.js?foo=bar')
);
$this->assertTags($result, $expected);
@@ -961,7 +960,7 @@ public function testPluginScript() {
$result = $this->Html->script('TestPlugin.jquery-1.3.2', array('defer' => true, 'encoding' => 'utf-8'));
$expected = array(
- 'script' => array('type' => 'text/javascript', 'src' => 'test_plugin/js/jquery-1.3.2.js', 'defer' => 'defer', 'encoding' => 'utf-8')
+ 'script' => array('src' => 'test_plugin/js/jquery-1.3.2.js', 'defer' => 'defer', 'encoding' => 'utf-8')
);
$this->assertTags($result, $expected);
@@ -1006,15 +1005,15 @@ public function testScriptWithFullBase() {
$result = $this->Html->script('foo', array('fullBase' => true));
$expected = array(
- 'script' => array('type' => 'text/javascript', 'src' => $here . 'js/foo.js')
+ 'script' => array('src' => $here . 'js/foo.js')
);
$this->assertTags($result, $expected);
$result = $this->Html->script(array('foobar', 'bar'), array('fullBase' => true));
$expected = array(
- array('script' => array('type' => 'text/javascript', 'src' => $here . 'js/foobar.js')),
+ array('script' => array('src' => $here . 'js/foobar.js')),
'/script',
- array('script' => array('type' => 'text/javascript', 'src' => $here . 'js/bar.js')),
+ array('script' => array('src' => $here . 'js/bar.js')),
'/script',
);
$this->assertTags($result, $expected);
@@ -1036,7 +1035,7 @@ public function testScriptInTheme() {
$this->Html->theme = 'test_theme';
$result = $this->Html->script('__test_js.js');
$expected = array(
- 'script' => array('src' => '/theme/test_theme/js/__test_js.js', 'type' => 'text/javascript')
+ 'script' => array('src' => '/theme/test_theme/js/__test_js.js')
);
$this->assertTags($result, $expected);
}
@@ -1049,7 +1048,7 @@ public function testScriptInTheme() {
public function testScriptBlock() {
$result = $this->Html->scriptBlock('window.foo = 2;');
$expected = array(
- 'script' => array('type' => 'text/javascript'),
+ '<script',
$this->cDataStart,
'window.foo = 2;',
$this->cDataEnd,
@@ -1069,15 +1068,15 @@ public function testScriptBlock() {
$result = $this->Html->scriptBlock('window.foo = 2;', array('safe' => false));
$expected = array(
- 'script' => array('type' => 'text/javascript'),
+ '<script',
'window.foo = 2;',
'/script',
);
$this->assertTags($result, $expected);
$result = $this->Html->scriptBlock('window.foo = 2;', array('safe' => true));
$expected = array(
- 'script' => array('type' => 'text/javascript'),
+ '<script',
$this->cDataStart,
'window.foo = 2;',
$this->cDataEnd,
@@ -1101,7 +1100,7 @@ public function testScriptBlock() {
$result = $this->Html->scriptBlock('window.foo = 2;', array('safe' => false, 'encoding' => 'utf-8'));
$expected = array(
- 'script' => array('type' => 'text/javascript', 'encoding' => 'utf-8'),
+ 'script' => array('encoding' => 'utf-8'),
'window.foo = 2;',
'/script',
);
@@ -1120,7 +1119,7 @@ public function testScriptStartAndScriptEnd() {
$result = $this->Html->scriptEnd();
$expected = array(
- 'script' => array('type' => 'text/javascript'),
+ '<script',
$this->cDataStart,
'this is some javascript',
$this->cDataEnd,
@@ -1134,7 +1133,7 @@ public function testScriptStartAndScriptEnd() {
$result = $this->Html->scriptEnd();
$expected = array(
- 'script' => array('type' => 'text/javascript'),
+ '<script',
'this is some javascript',
'/script'
);

0 comments on commit 5c49e13

Please sign in to comment.