mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
Merge pull request #143 from Innovatif/sapphire
--- BUGFIX Having <header tag in HTML causes requirements to double. See http://www.silverstripe.org/general-questions/show/17524
This commit is contained in:
parent
7d245c3803
commit
565e2ab318
@ -264,6 +264,24 @@ class RequirementsTest extends SapphireTest {
|
||||
$backend->assertFileIncluded('css', array($basePath .'/RequirementsTest_b.css', $basePath .'/RequirementsTest_c.css'));
|
||||
Requirements::set_backend($holder);
|
||||
}
|
||||
|
||||
function testJsWriteToBody() {
|
||||
$backend = new Requirements_Backend();
|
||||
$backend->javascript('http://www.mydomain.com/test.js');
|
||||
|
||||
// Test matching with HTML5 <header> tags as well
|
||||
$template = '<html><head></head><body><header>My header</header><p>Body</p></body></html>';
|
||||
|
||||
$backend->set_write_js_to_body(false);
|
||||
$html = $backend->includeInHTML(false, $template);
|
||||
$this->assertContains('<head><script', $html);
|
||||
|
||||
$backend->set_write_js_to_body(true);
|
||||
$html = $backend->includeInHTML(false, $template);
|
||||
$this->assertNotContains('<head><script', $html);
|
||||
$this->assertContains('</script></body>', $html);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
class RequirementsTest_Backend extends Requirements_Backend implements TestOnly {
|
||||
|
@ -645,7 +645,7 @@ class Requirements_Backend {
|
||||
function includeInHTML($templateFile, $content) {
|
||||
if(isset($_GET['debug_profile'])) Profiler::mark("Requirements::includeInHTML");
|
||||
|
||||
if(strpos($content, '</head') !== false && ($this->css || $this->javascript || $this->customCSS || $this->customScript || $this->customHeadTags)) {
|
||||
if((strpos($content, '</head>') !== false || strpos($content, '</head ') !== false) && ($this->css || $this->javascript || $this->customCSS || $this->customScript || $this->customHeadTags)) {
|
||||
$requirements = '';
|
||||
$jsRequirements = '';
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user