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

Commit

Permalink
Merge branch 'feature/96' into develop
Browse files Browse the repository at this point in the history
Close #96
  • Loading branch information
weierophinney committed Mar 21, 2017
2 parents 39e5758 + 79e49c8 commit cb05c31
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 41 deletions.
8 changes: 6 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,12 @@ All notable changes to this project will be documented in this file, in reverse
### Added

- [#89](https://github.com/zendframework/zend-view/pull/89) updates the
`HeadScript` view helper to whitelist the `id` attribute as an optional
attribute.
`HeadScript` and `InlineScript` view helpers to whitelist the `id` attribute
as an optional attribute.

- [#96](https://github.com/zendframework/zend-view/pull/96) updates the
`HeadScript`, `HeadLink`, and `InlineScript` view helpers to whitelist the
`crossorigin` and `integrity` attributes as optional attributes.

### Deprecated

Expand Down
16 changes: 8 additions & 8 deletions doc/book/helpers/head-link.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ elements for later retrieval and output in your layout script.
The `HeadLink` helper has special methods for adding stylesheet links to its
stack:

- `appendStylesheet($href, $media, $conditionalStylesheet, $extras)`
- `offsetSetStylesheet($index, $href, $media, $conditionalStylesheet, $extras)`
- `prependStylesheet($href, $media, $conditionalStylesheet, $extras)`
- `setStylesheet($href, $media, $conditionalStylesheet, $extras)`
- `appendStylesheet($href, $media = 'screen', $conditionalStylesheet = '', $extras = [])`
- `offsetSetStylesheet($index, $href, $media = 'screen', $conditionalStylesheet = '', $extras = [])`
- `prependStylesheet($href, $media = 'screen', $conditionalStylesheet = '', $extras = [])`
- `setStylesheet($href, $media = 'screen', $conditionalStylesheet = '', $extras = [])`

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

- `appendAlternate($href, $type, $title, $extras)`
- `offsetSetAlternate($index, $href, $type, $title, $extras)`
- `prependAlternate($href, $type, $title, $extras)`
- `setAlternate($href, $type, $title, $extras)`
- `appendAlternate($href, $type, $title, $extras = [])`
- `offsetSetAlternate($index, $href, $type, $title, $extras = [])`
- `prependAlternate($href, $type, $title, $extras = [])`
- `setAlternate($href, $type, $title, $extras = [])`

The `headLink()` helper method allows specifying all attributes necessary for a
`<link>` element, and allows you to also specify placement: whether the
Expand Down
21 changes: 11 additions & 10 deletions doc/book/helpers/head-script.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ code. The `HeadScript` helper allows you to manage both.

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

- `appendFile($src, $type = 'text/javascript', $attrs = array())`
- `offsetSetFile($index, $src, $type = 'text/javascript', $attrs = array())`
- `prependFile($src, $type = 'text/javascript', $attrs = array())`
- `setFile($src, $type = 'text/javascript', $attrs = array())`
- `appendScript($script, $type = 'text/javascript', $attrs = array())`
- `offsetSetScript($index, $script, $type = 'text/javascript', $attrs = array())`
- `prependScript($script, $type = 'text/javascript', $attrs = array())`
- `setScript($script, $type = 'text/javascript', $attrs = array())`
- `appendFile($src, $type = 'text/javascript', $attrs = [])`
- `offsetSetFile($index, $src, $type = 'text/javascript', $attrs = [])`
- `prependFile($src, $type = 'text/javascript', $attrs = [])`
- `setFile($src, $type = 'text/javascript', $attrs = [])`
- `appendScript($script, $type = 'text/javascript', $attrs = [])`
- `offsetSetScript($index, $script, $type = 'text/javascript', $attrs = [])`
- `prependScript($script, $type = 'text/javascript', $attrs = [])`
- `setScript($script, $type = 'text/javascript', $attrs = [])`

In the case of the `*File()` methods, `$src` is the remote location of the
script to load; this is usually in the form of a URL or a path. For the
Expand Down Expand Up @@ -86,8 +86,9 @@ The `HeadScript` helper is a concrete implementation of the
> ### Arbitrary Attributes are Disabled by Default
>
> By default, `HeadScript` only will render `<script>` attributes that are blessed by the W3C.
> These include `type`, `charset`, `defer`, `language`, and `src`. However, some JavaScript
> frameworks, notably [Dojo](http://www.dojotoolkit.org/), utilize custom attributes in order to
> These include `id`, `charset`, `crossorigin`, `defer`, `integrity`,
> `language`, `src`, and `type`. However, some JavaScript frameworks, notably
> [Dojo](http://www.dojotoolkit.org/), utilize custom attributes in order to
> modify behavior. To allow such attributes, you can enable them via the
> `setAllowArbitraryAttributes()` method:
>
Expand Down
8 changes: 4 additions & 4 deletions doc/book/helpers/head-style.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ The HTML `<style>` element is used to include CSS stylesheets inline in the HTML
The `HeadStyle` helper supports the following methods for setting and adding stylesheet
declarations:

- `appendStyle($content, $attributes = array())`
- `offsetSetStyle($index, $content, $attributes = array())`
- `prependStyle($content, $attributes = array())`
- `setStyle($content, $attributes = array())`
- `appendStyle($content, $attributes = [])`
- `offsetSetStyle($index, $content, $attributes = [])`
- `prependStyle($content, $attributes = [])`
- `setStyle($content, $attributes = [])`

In all cases, `$content` is the actual CSS declarations. `$attributes` are any
additional attributes you wish to provide to the `style` tag: lang, title,
Expand Down
20 changes: 11 additions & 9 deletions src/Helper/HeadLink.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@
* @see http://www.w3.org/TR/xhtml1/dtds.html
*
* Creates the following virtual methods:
* @method HeadLink appendStylesheet($href, $media = 'screen', $conditionalStylesheet = '', $extras = array())
* @method HeadLink offsetSetStylesheet($index, $href, $media = 'screen', $conditionalStylesheet = '', $extras = array())
* @method HeadLink prependStylesheet($href, $media = 'screen', $conditionalStylesheet = '', $extras = array())
* @method HeadLink setStylesheet($href, $media = 'screen', $conditionalStylesheet = '', $extras = array())
* @method HeadLink appendAlternate($href, $type, $title, $extras = array())
* @method HeadLink offsetSetAlternate($index, $href, $type, $title, $extras = array())
* @method HeadLink prependAlternate($href, $type, $title, $extras = array())
* @method HeadLink setAlternate($href, $type, $title, $extras = array())
* @method HeadLink appendStylesheet($href, $media = 'screen', $conditionalStylesheet = '', $extras = [])
* @method HeadLink offsetSetStylesheet($index, $href, $media = 'screen', $conditionalStylesheet = '', $extras = [])
* @method HeadLink prependStylesheet($href, $media = 'screen', $conditionalStylesheet = '', $extras = [])
* @method HeadLink setStylesheet($href, $media = 'screen', $conditionalStylesheet = '', $extras = [])
* @method HeadLink appendAlternate($href, $type, $title, $extras = [])
* @method HeadLink offsetSetAlternate($index, $href, $type, $title, $extras = [])
* @method HeadLink prependAlternate($href, $type, $title, $extras = [])
* @method HeadLink setAlternate($href, $type, $title, $extras = [])
*/
// @codingStandardsIgnoreEnd
class HeadLink extends Placeholder\Container\AbstractStandalone
Expand All @@ -49,7 +49,9 @@ class HeadLink extends Placeholder\Container\AbstractStandalone
'type',
'title',
'extras',
'itemprop'
'itemprop',
'crossorigin',
'integrity'
];

/**
Expand Down
17 changes: 9 additions & 8 deletions src/Helper/HeadScript.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@
* Helper for setting and retrieving script elements for HTML head section
*
* Allows the following method calls:
* @method HeadScript appendFile($src, $type = 'text/javascript', $attrs = array())
* @method HeadScript offsetSetFile($index, $src, $type = 'text/javascript', $attrs = array())
* @method HeadScript prependFile($src, $type = 'text/javascript', $attrs = array())
* @method HeadScript setFile($src, $type = 'text/javascript', $attrs = array())
* @method HeadScript appendScript($script, $type = 'text/javascript', $attrs = array())
* @method HeadScript offsetSetScript($index, $src, $type = 'text/javascript', $attrs = array())
* @method HeadScript prependScript($script, $type = 'text/javascript', $attrs = array())
* @method HeadScript setScript($script, $type = 'text/javascript', $attrs = array())
* @method HeadScript appendFile($src, $type = 'text/javascript', $attrs = [])
* @method HeadScript offsetSetFile($index, $src, $type = 'text/javascript', $attrs = [])
* @method HeadScript prependFile($src, $type = 'text/javascript', $attrs = [])
* @method HeadScript setFile($src, $type = 'text/javascript', $attrs = [])
* @method HeadScript appendScript($script, $type = 'text/javascript', $attrs = [])
* @method HeadScript offsetSetScript($index, $src, $type = 'text/javascript', $attrs = [])
* @method HeadScript prependScript($script, $type = 'text/javascript', $attrs = [])
* @method HeadScript setScript($script, $type = 'text/javascript', $attrs = [])
*/
class HeadScript extends Placeholder\Container\AbstractStandalone
{
Expand Down Expand Up @@ -85,6 +85,7 @@ class HeadScript extends Placeholder\Container\AbstractStandalone
*/
protected $optionalAttributes = [
'charset',
'integrity',
'crossorigin',
'defer',
'async',
Expand Down

0 comments on commit cb05c31

Please sign in to comment.