isWildcardTag example

private static function validateAllowedRestrictionsPhase1(array $elements): void {
    if (!is_array($elements) || !Inspector::assertAllStrings(array_keys($elements))) {
      throw new \InvalidArgumentException('An array of key-value pairs must be provided, with HTML tag names as keys.');
    }
    foreach (array_keys($elements) as $html_tag_name) {
      if (trim($html_tag_name) !== $html_tag_name) {
        throw new \InvalidArgumentException(sprintf('The "%s" HTML tag contains trailing or leading whitespace.', $html_tag_name));
      }
      if ($html_tag_name[0] === '<' || $html_tag_name[-1] === '>') {
        throw new \InvalidArgumentException(sprintf('"%s" is not a HTML tag name, it is an actual HTML tag. Omit the angular brackets.', $html_tag_name));
      }
      if (self::isWildcardTag($html_tag_name)) {
        continue;
      }
      // Special case: the global attribute `*` HTML tag.       // @see https://html.spec.whatwg.org/multipage/dom.html#global-attributes       // @see validateAllowedRestrictionsPhase2()       // @see validateAllowedRestrictionsPhase4()       // @see validateAllowedRestrictionsPhase5()       if ($html_tag_name === '*') {
        continue;
      }
      // HTML elements must have a valid tag name.
Home | Imprint | This part of the site doesn't use cookies.