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

Commit cb05c31

Browse files
committed
Merge branch 'feature/96' into develop
Close #96
2 parents 39e5758 + 79e49c8 commit cb05c31

File tree

6 files changed

+49
-41
lines changed

6 files changed

+49
-41
lines changed

CHANGELOG.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,12 @@ All notable changes to this project will be documented in this file, in reverse
77
### Added
88

99
- [#89](https://github.com/zendframework/zend-view/pull/89) updates the
10-
`HeadScript` view helper to whitelist the `id` attribute as an optional
11-
attribute.
10+
`HeadScript` and `InlineScript` view helpers to whitelist the `id` attribute
11+
as an optional attribute.
12+
13+
- [#96](https://github.com/zendframework/zend-view/pull/96) updates the
14+
`HeadScript`, `HeadLink`, and `InlineScript` view helpers to whitelist the
15+
`crossorigin` and `integrity` attributes as optional attributes.
1216

1317
### Deprecated
1418

doc/book/helpers/head-link.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ elements for later retrieval and output in your layout script.
88
The `HeadLink` helper has special methods for adding stylesheet links to its
99
stack:
1010

11-
- `appendStylesheet($href, $media, $conditionalStylesheet, $extras)`
12-
- `offsetSetStylesheet($index, $href, $media, $conditionalStylesheet, $extras)`
13-
- `prependStylesheet($href, $media, $conditionalStylesheet, $extras)`
14-
- `setStylesheet($href, $media, $conditionalStylesheet, $extras)`
11+
- `appendStylesheet($href, $media = 'screen', $conditionalStylesheet = '', $extras = [])`
12+
- `offsetSetStylesheet($index, $href, $media = 'screen', $conditionalStylesheet = '', $extras = [])`
13+
- `prependStylesheet($href, $media = 'screen', $conditionalStylesheet = '', $extras = [])`
14+
- `setStylesheet($href, $media = 'screen', $conditionalStylesheet = '', $extras = [])`
1515

1616
The `$media` value defaults to 'screen', but may be any valid media value.
1717
`$conditionalStylesheet` is a string or boolean `false`, and will be used at
@@ -22,10 +22,10 @@ extra values that you want to be added to the tag.
2222
Additionally, the `HeadLink` helper has special methods for adding 'alternate'
2323
links to its stack:
2424

25-
- `appendAlternate($href, $type, $title, $extras)`
26-
- `offsetSetAlternate($index, $href, $type, $title, $extras)`
27-
- `prependAlternate($href, $type, $title, $extras)`
28-
- `setAlternate($href, $type, $title, $extras)`
25+
- `appendAlternate($href, $type, $title, $extras = [])`
26+
- `offsetSetAlternate($index, $href, $type, $title, $extras = [])`
27+
- `prependAlternate($href, $type, $title, $extras = [])`
28+
- `setAlternate($href, $type, $title, $extras = [])`
2929

3030
The `headLink()` helper method allows specifying all attributes necessary for a
3131
`<link>` element, and allows you to also specify placement: whether the

doc/book/helpers/head-script.md

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ code. The `HeadScript` helper allows you to manage both.
66

77
The `HeadScript` helper supports the following methods for setting and adding scripts:
88

9-
- `appendFile($src, $type = 'text/javascript', $attrs = array())`
10-
- `offsetSetFile($index, $src, $type = 'text/javascript', $attrs = array())`
11-
- `prependFile($src, $type = 'text/javascript', $attrs = array())`
12-
- `setFile($src, $type = 'text/javascript', $attrs = array())`
13-
- `appendScript($script, $type = 'text/javascript', $attrs = array())`
14-
- `offsetSetScript($index, $script, $type = 'text/javascript', $attrs = array())`
15-
- `prependScript($script, $type = 'text/javascript', $attrs = array())`
16-
- `setScript($script, $type = 'text/javascript', $attrs = array())`
9+
- `appendFile($src, $type = 'text/javascript', $attrs = [])`
10+
- `offsetSetFile($index, $src, $type = 'text/javascript', $attrs = [])`
11+
- `prependFile($src, $type = 'text/javascript', $attrs = [])`
12+
- `setFile($src, $type = 'text/javascript', $attrs = [])`
13+
- `appendScript($script, $type = 'text/javascript', $attrs = [])`
14+
- `offsetSetScript($index, $script, $type = 'text/javascript', $attrs = [])`
15+
- `prependScript($script, $type = 'text/javascript', $attrs = [])`
16+
- `setScript($script, $type = 'text/javascript', $attrs = [])`
1717

1818
In the case of the `*File()` methods, `$src` is the remote location of the
1919
script to load; this is usually in the form of a URL or a path. For the
@@ -86,8 +86,9 @@ The `HeadScript` helper is a concrete implementation of the
8686
> ### Arbitrary Attributes are Disabled by Default
8787
>
8888
> By default, `HeadScript` only will render `<script>` attributes that are blessed by the W3C.
89-
> These include `type`, `charset`, `defer`, `language`, and `src`. However, some JavaScript
90-
> frameworks, notably [Dojo](http://www.dojotoolkit.org/), utilize custom attributes in order to
89+
> These include `id`, `charset`, `crossorigin`, `defer`, `integrity`,
90+
> `language`, `src`, and `type`. However, some JavaScript frameworks, notably
91+
> [Dojo](http://www.dojotoolkit.org/), utilize custom attributes in order to
9192
> modify behavior. To allow such attributes, you can enable them via the
9293
> `setAllowArbitraryAttributes()` method:
9394
>

doc/book/helpers/head-style.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ The HTML `<style>` element is used to include CSS stylesheets inline in the HTML
1212
The `HeadStyle` helper supports the following methods for setting and adding stylesheet
1313
declarations:
1414

15-
- `appendStyle($content, $attributes = array())`
16-
- `offsetSetStyle($index, $content, $attributes = array())`
17-
- `prependStyle($content, $attributes = array())`
18-
- `setStyle($content, $attributes = array())`
15+
- `appendStyle($content, $attributes = [])`
16+
- `offsetSetStyle($index, $content, $attributes = [])`
17+
- `prependStyle($content, $attributes = [])`
18+
- `setStyle($content, $attributes = [])`
1919

2020
In all cases, `$content` is the actual CSS declarations. `$attributes` are any
2121
additional attributes you wish to provide to the `style` tag: lang, title,

src/Helper/HeadLink.php

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@
2020
* @see http://www.w3.org/TR/xhtml1/dtds.html
2121
*
2222
* Creates the following virtual methods:
23-
* @method HeadLink appendStylesheet($href, $media = 'screen', $conditionalStylesheet = '', $extras = array())
24-
* @method HeadLink offsetSetStylesheet($index, $href, $media = 'screen', $conditionalStylesheet = '', $extras = array())
25-
* @method HeadLink prependStylesheet($href, $media = 'screen', $conditionalStylesheet = '', $extras = array())
26-
* @method HeadLink setStylesheet($href, $media = 'screen', $conditionalStylesheet = '', $extras = array())
27-
* @method HeadLink appendAlternate($href, $type, $title, $extras = array())
28-
* @method HeadLink offsetSetAlternate($index, $href, $type, $title, $extras = array())
29-
* @method HeadLink prependAlternate($href, $type, $title, $extras = array())
30-
* @method HeadLink setAlternate($href, $type, $title, $extras = array())
23+
* @method HeadLink appendStylesheet($href, $media = 'screen', $conditionalStylesheet = '', $extras = [])
24+
* @method HeadLink offsetSetStylesheet($index, $href, $media = 'screen', $conditionalStylesheet = '', $extras = [])
25+
* @method HeadLink prependStylesheet($href, $media = 'screen', $conditionalStylesheet = '', $extras = [])
26+
* @method HeadLink setStylesheet($href, $media = 'screen', $conditionalStylesheet = '', $extras = [])
27+
* @method HeadLink appendAlternate($href, $type, $title, $extras = [])
28+
* @method HeadLink offsetSetAlternate($index, $href, $type, $title, $extras = [])
29+
* @method HeadLink prependAlternate($href, $type, $title, $extras = [])
30+
* @method HeadLink setAlternate($href, $type, $title, $extras = [])
3131
*/
3232
// @codingStandardsIgnoreEnd
3333
class HeadLink extends Placeholder\Container\AbstractStandalone
@@ -49,7 +49,9 @@ class HeadLink extends Placeholder\Container\AbstractStandalone
4949
'type',
5050
'title',
5151
'extras',
52-
'itemprop'
52+
'itemprop',
53+
'crossorigin',
54+
'integrity'
5355
];
5456

5557
/**

src/Helper/HeadScript.php

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@
1717
* Helper for setting and retrieving script elements for HTML head section
1818
*
1919
* Allows the following method calls:
20-
* @method HeadScript appendFile($src, $type = 'text/javascript', $attrs = array())
21-
* @method HeadScript offsetSetFile($index, $src, $type = 'text/javascript', $attrs = array())
22-
* @method HeadScript prependFile($src, $type = 'text/javascript', $attrs = array())
23-
* @method HeadScript setFile($src, $type = 'text/javascript', $attrs = array())
24-
* @method HeadScript appendScript($script, $type = 'text/javascript', $attrs = array())
25-
* @method HeadScript offsetSetScript($index, $src, $type = 'text/javascript', $attrs = array())
26-
* @method HeadScript prependScript($script, $type = 'text/javascript', $attrs = array())
27-
* @method HeadScript setScript($script, $type = 'text/javascript', $attrs = array())
20+
* @method HeadScript appendFile($src, $type = 'text/javascript', $attrs = [])
21+
* @method HeadScript offsetSetFile($index, $src, $type = 'text/javascript', $attrs = [])
22+
* @method HeadScript prependFile($src, $type = 'text/javascript', $attrs = [])
23+
* @method HeadScript setFile($src, $type = 'text/javascript', $attrs = [])
24+
* @method HeadScript appendScript($script, $type = 'text/javascript', $attrs = [])
25+
* @method HeadScript offsetSetScript($index, $src, $type = 'text/javascript', $attrs = [])
26+
* @method HeadScript prependScript($script, $type = 'text/javascript', $attrs = [])
27+
* @method HeadScript setScript($script, $type = 'text/javascript', $attrs = [])
2828
*/
2929
class HeadScript extends Placeholder\Container\AbstractStandalone
3030
{
@@ -85,6 +85,7 @@ class HeadScript extends Placeholder\Container\AbstractStandalone
8585
*/
8686
protected $optionalAttributes = [
8787
'charset',
88+
'integrity',
8889
'crossorigin',
8990
'defer',
9091
'async',

0 commit comments

Comments
 (0)