<commit_before>define(
  'ephox.echo.api.AriaVoice',

  [
    'ephox.epithet.Id',
    'ephox.fred.PlatformDetection',
    'ephox.peanut.Fun',
    'ephox.sugar.api.Attr',
    'ephox.sugar.api.Css',
    'ephox.sugar.api.Element',
    'ephox.sugar.api.Insert',
    'ephox.sugar.api.Remove',
    'ephox.sugar.api.Traverse',
    'global!setTimeout'
  ],

  function (Id, PlatformDetection, Fun, Attr, Css, Element, Insert, Remove, Traverse, setTimeout) {
    var isFirefox = PlatformDetection.detect().browser.isFirefox();

    var offscreen = {
      position: 'absolute',
      left: '-9999px'
    };

    var tokenSelector = function () {
      return 'span[id^="ephox-echo-voice"]';
    };

    var create = function (doc, text) {
      var span = Element.fromTag('span', doc.dom());
      // This stops it saying other things (possibly blank) between transitions.
      var contents = Element.fromText(text, doc.dom());
      Insert.append(span, contents);
      return span;
    };

    var describe = function (item, description) {
      var doc = Traverse.owner(item);
      var token = create(doc, description);
      var id = Id.generate('ephox-echo-voice');
      Attr.set(token, 'id', id);

      // We may not be able to get rid of them, so we'll make them display: none;
      Css.set(token, 'display', 'none');

      // Although described-by does not appear to work in IE10, we are currently only supporting JAWS in Firefox (and IE11),
      // and this does work for those browsers.
      Attr.set(item, 'aria-describedby', id);
      return token;
    };

    var base = function (getAttrs, parent, text) {
      var doc = Traverse.owner(parent);

      // firefox needs aria-describedby to speak a role=alert token, which causes IE11 to read twice
      var createToken = isFirefox ? Fun.curry(describe, parent) : Fun.curry(create, doc);
      var token = createToken(text);

      // Make it speak as soon as it is in the DOM (politely)
      Attr.setAll(token, getAttrs(text));

      Css.setAll(token, offscreen);

      Insert.append(parent, token);

      // Remove the token later.
      setTimeout(function () {
        // If you don't remove this attribute, IE11 speaks the removal
        Attr.remove(token, 'aria-live');
        Remove.remove(token);
      }, 1000);<commit_msg>TBIO-3371: TBIO-3371: not using describe in base<commit_after>define(
  'ephox.echo.api.AriaVoice',

  [
    'ephox.epithet.Id',
    'ephox.fred.PlatformDetection',
    'ephox.peanut.Fun',
    'ephox.sugar.api.Attr',
    'ephox.sugar.api.Css',
    'ephox.sugar.api.Element',
    'ephox.sugar.api.Insert',
    'ephox.sugar.api.Remove',
    'ephox.sugar.api.Traverse',
    'global!setTimeout'
  ],

  function (Id, PlatformDetection, Fun, Attr, Css, Element, Insert, Remove, Traverse, setTimeout) {
    var isFirefox = PlatformDetection.detect().browser.isFirefox();

    var offscreen = {
      position: 'absolute',
      left: '-9999px'
    };

    var tokenSelector = function () {
      return 'span[id^="ephox-echo-voice"]';
    };

    var create = function (doc, text) {
      var span = Element.fromTag('span', doc.dom());
      // This stops it saying other things (possibly blank) between transitions.
      var contents = Element.fromText(text, doc.dom());
      Insert.append(span, contents);
      return span;
    };

    var linkToDescription = function (item, token) {
      var id = Id.generate('ephox-echo-voice');
      Attr.set(token, 'id', id);
      Attr.set(item, 'aria-describedby', id);
    };

    var describe = function (item, description) {
      var doc = Traverse.owner(item);
      var token = create(doc, description);
      
      // We may not be able to get rid of them, so we'll make them display: none;
      Css.set(token, 'display', 'none');

      // Although described-by does not appear to work in IE10, we are currently only supporting JAWS in Firefox (and IE11),
      // and this does work for those browsers.
      linkToDescription(item, token);
      
      return token;
    };

    var base = function (getAttrs, parent, text) {
      var doc = Traverse.owner(parent);

      // firefox needs aria-describedby to speak a role=alert token, which causes IE11 to read twice
      var token = create(doc, text);
      if (isFirefox) linkToDescription(parent, token);

      // Make it speak as soon as it is in the DOM (politely)
      Attr.setAll(token, getAttrs(text));
      Css.setAll(token, offscreen);

      Insert.append(parent, token);

      // Remove the token later.
      setTimeout(function () {
        // If you don't remove this attribute, IE11 speaks the removal
        Attr.remove(token, 'aria-live');
        Remove.remove(token);
      }, 1000);
{'fraction_non_alphanumeric': 0.13149522799575822, 'fraction_numerical': 0.008483563096500531, 'mean_word_length': 2.7046347211311863, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6946496', 'n_tokens_mistral': 1532, 'n_tokens_neox': 1471, 'n_words': 414}