3 namespace Drupal\http2_server_push\Asset;
5 trait AssetHtmlTagRenderElementTrait {
8 * Whether the render element is a <link rel=stylesheet>.
10 * @param array $element
15 protected static function isLinkRelStylesheet(array $element) {
17 (isset($element['#type']) && $element['#type'] === 'html_tag')
19 (isset($element['#tag']) && $element['#tag'] === 'link')
21 (isset($element['#attributes']) && isset($element['#attributes']['rel']) && $element['#attributes']['rel'] === 'stylesheet');
25 * Whether the render element is a <script>.
27 * @param array $element
32 protected static function isScript(array $element) {
34 (isset($element['#type']) && $element['#type'] === 'html_tag')
36 (isset($element['#tag']) && $element['#tag'] === 'script');
40 * Whether the render element is unconditional.
42 * An unconditional element is not browser-specific, i.e. is not wrapped in a
43 * conditional comment via the '#browsers' property.
45 * @see \Drupal\Core\Render\Element\HtmlTag::preRenderConditionalComments
47 * @param array $element
52 protected static function isUnconditional(array $element) {
53 return empty($element['#browsers']) || ($element['#browsers']['!IE'] === TRUE && $element['#browsers']['IE'] === TRUE);
57 * Whether the given attribute on the render element has a root-relative URL.
59 * @param array $element
64 protected static function hasRootRelativeUrl(array $element, $attribute_name) {
65 $attribute_value = $element['#attributes'][$attribute_name];
66 return $attribute_value[0] === '/' && $attribute_value[1] !== '/';