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

Commit

Permalink
Merge pull request #96 from akrause414/head-script-integrity-improvement
Browse files Browse the repository at this point in the history
Allow integrity & crossorigin on head srcript/link
  • Loading branch information
weierophinney committed Mar 21, 2017
2 parents 39e5758 + 857dd76 commit 103ae4e
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 38 deletions.
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
18 changes: 9 additions & 9 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,7 +86,7 @@ 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
> These include `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 103ae4e

Please sign in to comment.