1 common.inc backdrop_pre_render_conditional_comments($elements)

Pre-render callback: Provides backwards-compatibility for #browsers property.

@since 1.27.0 Conditional comments are no longer rendered.

Parameters

$elements: A render array with a '#browsers' property. This property formerly provided the ability target IE vs. non-IE browsers. However, it no longer provides this functionality as this has not been supported since IE10. Now if the '#browsers' property is set it will do one of the following:

  • '!IE': If TRUE, the element will be returned with no modifications. If FALSE, the element will not be rendered at all.

    • 'IE': Any value passed in this key will be ignored.

Return value

array: A placeholder array for IE-specific files, or the unmodified element if this element would render in any non-IE browser.

Deprecated

Since 1.27.0

File

core/includes/common.inc, line 6499
Common functions that many Backdrop modules will need to reference.

Code

function backdrop_pre_render_conditional_comments($elements) {
  $browsers = isset($elements['#browsers']) ? $elements['#browsers'] : array();
  $browsers += array(
    'IE' => TRUE,
    '!IE' => TRUE,
  );

  // If not allowed to output to non-IE browsers, suppress the element entirely.
  if ($browsers['!IE'] === FALSE) {
    return array(
      '#type' => NULL,
      '#value' => 'Element removed, the "browsers" property targeting only IE browsers is no longer supported.',
    );
  }

  return $elements;
}