Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// this is not equivalent to the declaration from `getComputedStyle`
// e.g `getComputedStyle` would return a readonly declaration
// let's hope this doesn't get passed around until it's no longer clear where it comes from
const declaration = document.createElement('span').style;
// initial values
declaration.content = '';
// technically it's `inline`. We partially apply the default user agent sheet (chrome) here
// we're only interested in elements that use block
declaration.display = blockElements.has(element.tagName) ? 'block' : 'inline';
declaration.visibility = 'visible';
return declaration;
}
const actualName = computeAccessibleName(root, {
// in local development we pretend to be visible. full getComputedStyle is
// expensive and reserved for CI
getComputedStyle: process.env.CI ? undefined : pretendVisibleGetComputedStyle,
});
this.assert(
actualName === expectedName,
`expected ${utils.elToString(
root,
)} to have accessible name '${expectedName}' but got '${actualName}' instead.`,
`expected ${utils.elToString(root)} not to have accessible name '${expectedName}'.`,
);
});
});