MDL-75982 tiny_accessibilitychecker: Fall back to opaque white as top background

This commit is contained in:
Andrew Nicols 2022-11-18 11:34:08 +08:00
parent 4024127ee0
commit e82229eea6
3 changed files with 10 additions and 3 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -456,8 +456,15 @@ export default class {
* @private
*/
getComputedBackgroundColor(node, color) {
if (!node.parentNode) {
// This is the document node and has no colour.
// We cannot use window.getComputedStyle on the document.
// If we got here, then the document has no background colour. Fall back to white.
return this.colorBase.toArray('rgba(255, 255, 255, 1)');
}
color = color ? color : window.getComputedStyle(node, null).getPropertyValue('background-color');
if (color.toLowerCase() === 'transparent') {
if (color.toLowerCase() === 'rgba(0, 0, 0, 0)' || color.toLowerCase() === 'transparent') {
color = 'rgba(1, 1, 1, 0)';
}