Skip to content
This repository was archived by the owner on Jan 31, 2020. It is now read-only.

Commit bec56ca

Browse files
committed
Merge branch 'hotfix/22'
Close #22
2 parents 8fe98ad + 8c216d4 commit bec56ca

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ All notable changes to this project will be documented in this file, in reverse
66

77
### Added
88

9-
- Nothing.
9+
- [#22](https://github.com/zendframework/zend-view/pull/22) adds support for the
10+
`async` attribute within the `headScript` helper.
1011

1112
### Deprecated
1213

src/Helper/HeadScript.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ class HeadScript extends Placeholder\Container\AbstractStandalone
8787
'charset',
8888
'crossorigin',
8989
'defer',
90+
'async',
9091
'language',
9192
'src',
9293
];
@@ -393,6 +394,9 @@ public function itemToString($item, $indent, $escapeStart, $escapeEnd)
393394
if ('defer' == $key) {
394395
$value = 'defer';
395396
}
397+
if ('async' == $key) {
398+
$value = 'async';
399+
}
396400
$attrString .= sprintf(' %s="%s"', $key, ($this->autoEscape) ? $this->escape($value) : $value);
397401
}
398402
}

test/Helper/HeadScriptTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -491,4 +491,18 @@ public function testOmitsTypeAttributeIfEmptyValueAndHtml5Doctype()
491491
$test = $this->helper->__invoke()->toString();
492492
$this->assertNotContains('type', $test);
493493
}
494+
495+
/**
496+
* @group 22
497+
*/
498+
public function testSupportsAsyncAttribute()
499+
{
500+
$this->helper->__invoke()->appendScript(
501+
'// some script' . PHP_EOL,
502+
'text/javascript',
503+
['async' => true]
504+
);
505+
$test = $this->helper->__invoke()->toString();
506+
$this->assertContains('async="', $test);
507+
}
494508
}

0 commit comments

Comments
 (0)