Skip to content

Commit

Permalink
Allow ARIA attributes in all elements
Browse files Browse the repository at this point in the history
This allows any attribute that starts with aria- and contains only letters (which covers all existing aria attributes at this time).
  • Loading branch information
saschaleib committed Oct 6, 2023
1 parent 0fe37dd commit e97278e
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,14 @@ function buildAttributes($data, $myObj, $addClass='', $mode='xhtml') {

default:

/* special case: data- attributes: */
/* special case 1: data-* attributes: */
if (preg_match('/^data-[a-z][a-z0-9_-]*$/', $key)) {
$out .= ' '.$key.'="'.hsc(strtolower($val)).'"';
$out .= ' '.$key.'="'.hsc($val).'"';
}

/* special case 2: aria-* attributes: */
if (preg_match('/^aria-[a-z]+$/', $key)) {
$out .= ' '.$key.'="'.hsc($val).'"';
}

/* any other attribute: ask the class if it is allowed: */
Expand Down

0 comments on commit e97278e

Please sign in to comment.