How to use the dom-accessibility-api.computeAccessibleName function in dom-accessibility-api

To help you get started, we’ve selected a few dom-accessibility-api examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mui-org / material-ui / test / utils / initMatchers.js View on Github external
// 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}'.`,
    );
  });
});

dom-accessibility-api

Implements https://w3c.github.io/accname/

MIT
Latest version published 4 months ago

Package Health Score

83 / 100
Full package analysis

Popular dom-accessibility-api functions