-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Editable: Pass all aria-* props to TinyMCE
With this change, Editable expects ARIA attributes to be provided as individual props: `<Editable aria-label="foo" />`. This replaces the approach whereby a single `aria` object prop would be passed. This allows Editable's interface to be kept similar to any native element's interface. One benefit we now get for free is that the linter is able to warn the author if they pass an invalid ARIA attribute: aria-foo: This attribute is an invalid ARIA attribute. (jsx-a11y/aria-props) [eslint]
- Loading branch information
Showing
3 changed files
with
41 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
|
||
import { | ||
pickBy, | ||
startsWith, | ||
} from 'lodash'; | ||
|
||
const isAriaPropName = ( name ) => | ||
startsWith( name, 'aria-' ); | ||
|
||
export const getAriaKeys = ( props ) => | ||
Object.keys( props ).filter( isAriaPropName ); | ||
|
||
export const pickAriaProps = ( props ) => | ||
pickBy( props, ( value, key ) => isAriaPropName( key ) ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters