You are here

protected function OutputRules::nonBooleanAttribute in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/masterminds/html5/src/HTML5/Serializer/OutputRules.php \Masterminds\HTML5\Serializer\OutputRules::nonBooleanAttribute()
1 call to OutputRules::nonBooleanAttribute()
OutputRules::attrs in vendor/masterminds/html5/src/HTML5/Serializer/OutputRules.php

File

vendor/masterminds/html5/src/HTML5/Serializer/OutputRules.php, line 369
The rules for generating output in the serializer.

Class

OutputRules
Generate the output html5 based on element rules.

Namespace

Masterminds\HTML5\Serializer

Code

protected function nonBooleanAttribute(\DOMAttr $attr) {
  $ele = $attr->ownerElement;
  foreach ($this->nonBooleanAttributes as $rule) {
    if (isset($rule['nodeNamespace']) && $rule['nodeNamespace'] !== $ele->namespaceURI) {
      continue;
    }
    if (isset($rule['attNamespace']) && $rule['attNamespace'] !== $attr->namespaceURI) {
      continue;
    }
    if (isset($rule['nodeName']) && !is_array($rule['nodeName']) && $rule['nodeName'] !== $ele->localName) {
      continue;
    }
    if (isset($rule['nodeName']) && is_array($rule['nodeName']) && !in_array($ele->localName, $rule['nodeName'], true)) {
      continue;
    }
    if (isset($rule['attrName']) && !is_array($rule['attrName']) && $rule['attrName'] !== $attr->localName) {
      continue;
    }
    if (isset($rule['attrName']) && is_array($rule['attrName']) && !in_array($attr->localName, $rule['attrName'], true)) {
      continue;
    }
    if (isset($rule['xpath'])) {
      $xp = $this
        ->getXPath($attr);
      if (isset($rule['prefixes'])) {
        foreach ($rule['prefixes'] as $nsPrefix => $ns) {
          $xp
            ->registerNamespace($nsPrefix, $ns);
        }
      }
      if (!$xp
        ->evaluate($rule['xpath'], $attr)) {
        continue;
      }
    }
    return true;
  }
  return false;
}