Make WordPress Core

Changeset 41250


Ignore:
Timestamp:
08/14/2017 02:03:18 AM (7 years ago)
Author:
peterwilsoncc
Message:

Emoji: Update Twemoji to 2.5.0.

Twemoji 2.3.0 has a rendering issue in Safari, emoji can sometimes be followed by U+FEOF (which is just a flag meaning "render the preceding character as emoji).

Twemoji wasn't catching this character correctly, and Safari rendered it incorrectly.

Twemoji 2.5.0 resolves this issue.

Fixes #41584.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/js/twemoji.js

    r40837 r41250  
    8989      onerror: function onerror() {
    9090        if (this.parentNode) {
    91           this.parentNode.replaceChild(createText(this.alt), this);
     91          this.parentNode.replaceChild(createText(this.alt, false), this);
    9292        }
    9393      },
     
    160160       *
    161161       *  twemoji.parse("I \u2764\uFE0F emoji!");
    162        *  // I <img class="emoji" draggable="false" alt="❤️" src="/assets/2764.gif"> emoji!
     162       *  // I <img class="emoji" draggable="false" alt="❤️" src="/assets/2764.gif"/> emoji!
    163163       *
    164164       *
     
    166166       *    return '/assets/' + iconId + '.gif';
    167167       *  });
    168        *  // I <img class="emoji" draggable="false" alt="❤️" src="/assets/2764.gif"> emoji!
     168       *  // I <img class="emoji" draggable="false" alt="❤️" src="/assets/2764.gif"/> emoji!
    169169       *
    170170       *
     
    175175       *   }
    176176       * });
    177        *  // I <img class="emoji" draggable="false" alt="❤️" src="/assets/72x72/2764.png"> emoji!
     177       *  // I <img class="emoji" draggable="false" alt="❤️" src="/assets/72x72/2764.png"/> emoji!
    178178       *
    179179       */
     
    238238    rescaper = /[&<>'"]/g,
    239239
    240     // nodes with type 1 which should **not** be parsed (including lower case svg)
    241     shouldntBeParsed = /IFRAME|NOFRAMES|NOSCRIPT|SCRIPT|SELECT|STYLE|TEXTAREA|[a-z]/,
     240    // nodes with type 1 which should **not** be parsed
     241    shouldntBeParsed = /^(?:iframe|noframes|noscript|script|select|style|textarea)$/,
    242242
    243243    // just a private shortcut
     
    257257   * @return  Node  a DOM node with that text
    258258   */
    259   function createText(text) {
    260     return document.createTextNode(text);
     259  function createText(text, clean) {
     260    return document.createTextNode(clean ? text.replace(UFE0Fg, '') : text);
    261261  }
    262262
     
    302302        allText.push(subnode);
    303303      }
    304       // ignore all nodes that are not type 1 or that
     304      // ignore all nodes that are not type 1, that are svg, or that
    305305      // should not be parsed as script, style, and others
    306       else if (nodeType === 1 && !shouldntBeParsed.test(subnode.nodeName)) {
     306      else if (nodeType === 1 && !('ownerSVGElement' in subnode) &&
     307          !shouldntBeParsed.test(subnode.nodeName.toLowerCase())) {
    307308        grabAllTextNodes(subnode, allText);
    308309      }
     
    366367        if (index !== i) {
    367368          fragment.appendChild(
    368             createText(text.slice(i, index))
     369            createText(text.slice(i, index), true)
    369370          );
    370371        }
     
    394395          fragment.appendChild(img);
    395396        }
    396         if (!img) fragment.appendChild(createText(rawText));
     397        if (!img) fragment.appendChild(createText(rawText, false));
    397398        img = null;
    398399      }
     
    402403        if (i < text.length) {
    403404          fragment.appendChild(
    404             createText(text.slice(i))
     405            createText(text.slice(i), true)
    405406          );
    406407        }
     
    460461          }
    461462        }
    462         ret = ret.concat('>');
     463        ret = ret.concat('/>');
    463464      }
    464465      return ret;
Note: See TracChangeset for help on using the changeset viewer.