0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

[CakePHP 2.3.9]$this->Html->css(array('style'), null, array('inline' => false));を繰り返すと同じCSSが重複する

Posted at

事象

  • CakePHP 2.3.9において$this->Html->css(array('style'), null, array('inline' => false));で指定のCSSが繰り返した分だけ<head>に出現する。
  • $this->Html->script(array('script'), array('inline' => false));で指定のJSは重複しないのでCSSも同様の動作を期待していたものの異なる挙動だった。

コード例

  • elementで利用するctp内で定義。例えば下記のように3回出現すると...
<?php $this->Html->css(array('style'), null, array('inline' => false)); ?>
<?php $this->Html->css(array('style'), null, array('inline' => false)); ?>
<?php $this->Html->css(array('style'), null, array('inline' => false)); ?>
  • (期待)HTMLでは重複のない状態で出力される事を期待していた。
<link rel="stylesheet" type="text/css" href="/css/style.css" />
  • (実際)HTMLで繰り返し出力された。
<link rel="stylesheet" type="text/css" href="/css/style.css" />
<link rel="stylesheet" type="text/css" href="/css/style.css" />
<link rel="stylesheet" type="text/css" href="/css/style.css" />

ISSUEで報告済みの事象だった。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?