Skip to content

Commit

Permalink
Merge pull request #10 from Yoast/stories/af/9-strip-html
Browse files Browse the repository at this point in the history
Add simple replace to strip HTML tags.
  • Loading branch information
boblinthorst authored Oct 28, 2016
2 parents 20c58f4 + 6f5752e commit a968fff
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
9 changes: 9 additions & 0 deletions a11y-speak.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,15 @@ var A11ySpeak = function( message, ariaLive ) {
// Clear previous messages to allow repeated strings being read out.
clear();

/*
* Strip HTML tags (if any) from the message string. Ideally, messages should
* be simple strings, carefully crafted for specific use with A11ySpeak.
* When re-using already existing strings this will ensure simple HTML to be
* stripped out and replaced with a space. Browsers will collapse multiple
* spaces natively.
*/
message = message.replace( /<[^<>]+>/g, " " );

if ( containerAssertive && "assertive" === ariaLive ) {
containerAssertive.textContent = message;
} else if ( containerPolite ) {
Expand Down
2 changes: 1 addition & 1 deletion a11y-speak.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit a968fff

Please sign in to comment.