Merge branch 'master' into chore/remove-node-modules-codespell

This commit is contained in:
Manuel Doncel Martos 2025-08-18 11:27:41 +02:00 committed by GitHub
commit b502bb6faa
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 38 additions and 7 deletions

4
dist/reveal.esm.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

4
dist/reveal.js vendored

File diff suppressed because one or more lines are too long

2
dist/reveal.js.map vendored

File diff suppressed because one or more lines are too long

View file

@ -394,7 +394,7 @@ export default function( revealElement, options ) {
// Text node // Text node
if( node.nodeType === 3 ) { if( node.nodeType === 3 ) {
text += node.textContent; text += node.textContent.trim();
} }
// Element node // Element node
else if( node.nodeType === 1 ) { else if( node.nodeType === 1 ) {
@ -403,10 +403,25 @@ export default function( revealElement, options ) {
let isDisplayHidden = window.getComputedStyle( node )['display'] === 'none'; let isDisplayHidden = window.getComputedStyle( node )['display'] === 'none';
if( isAriaHidden !== 'true' && !isDisplayHidden ) { if( isAriaHidden !== 'true' && !isDisplayHidden ) {
// Capture alt text from img and video elements
if( node.tagName === 'IMG' || node.tagName === 'VIDEO' ) {
let altText = node.getAttribute( 'alt' );
if( altText ) {
text += ensurePunctuation( altText );
}
}
Array.from( node.childNodes ).forEach( child => { Array.from( node.childNodes ).forEach( child => {
text += getStatusText( child ); text += getStatusText( child );
} ); } );
// Add period after block-level text elements to improve
// screen reader experience
const textElements = ['P', 'DIV', 'UL', 'OL', 'LI', 'H1', 'H2', 'H3', 'H4', 'H5', 'H6', 'BLOCKQUOTE'];
if( textElements.includes( node.tagName ) && text.trim() !== '' ) {
text = ensurePunctuation( text );
}
} }
} }
@ -417,6 +432,22 @@ export default function( revealElement, options ) {
} }
/**
* Ensures text ends with proper punctuation by adding a period
* if it doesn't already end with punctuation.
*/
function ensurePunctuation( text ) {
const trimmedText = text.trim();
if( trimmedText === '' ) {
return text;
}
return !/[.!?]$/.test(trimmedText) ? trimmedText + '.' : trimmedText;
}
/** /**
* This is an unfortunate necessity. Some actions such as * This is an unfortunate necessity. Some actions such as
* an input field being focused in an iframe or using the * an input field being focused in an iframe or using the