[FIX] IE11 - callback createTreeWalker doesnt accept acceptNo… (#15157)

pull/15177/head
Guilherme Gazzo 6 years ago committed by GitHub
parent 3f7989e6b6
commit 9119b3290c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 22
      app/emoji/client/emojiParser.js
  2. 2
      app/markdown/lib/parser/original/markdown.js
  3. 15
      app/ui-utils/client/lib/isIE11.js
  4. 1
      imports/client/@rocket.chat/apps-engine

@ -3,6 +3,7 @@ import { Meteor } from 'meteor/meteor';
import { Tracker } from 'meteor/tracker';
import { getUserPreference } from '../../utils';
import { isIE11 } from '../../ui-utils/client/lib/isIE11';
import { callbacks } from '../../callbacks';
import { emoji } from '../lib/rocketchat';
@ -32,11 +33,10 @@ Tracker.autorun(() => {
const emojis = Array.from(checkEmojiOnly.querySelectorAll('.emoji:not(:empty), .emojione:not(:empty)'));
const walker = document.createTreeWalker(
checkEmojiOnly,
NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_TEXT,
{
acceptNode: (node) => {
let hasText = false;
if (!isIE11()) {
const filter = (node) => {
if (node.nodeType === Node.ELEMENT_NODE && (
node.classList.contains('emojione')
|| node.classList.contains('emoji')
@ -44,11 +44,14 @@ Tracker.autorun(() => {
return NodeFilter.FILTER_REJECT;
}
return NodeFilter.FILTER_ACCEPT;
},
},
};
const walker = document.createTreeWalker(
checkEmojiOnly,
NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_TEXT,
filter
);
let hasText = false;
while (walker.nextNode()) {
if (walker.currentNode.nodeType === Node.TEXT_NODE && walker.currentNode.nodeValue.trim() !== '') {
@ -56,7 +59,6 @@ Tracker.autorun(() => {
break;
}
}
const emojiOnly = emojis.length && !hasText;
if (emojiOnly) {
@ -66,6 +68,8 @@ Tracker.autorun(() => {
}
html = checkEmojiOnly.innerHTML;
}
}
// apostrophe (') back to '
html = html.replace(/\'/g, ''');

@ -23,7 +23,7 @@ const parseNotEscaped = function(msg, message) {
return token;
};
const schemes = settings.get('Markdown_SupportSchemesForLink').split(',').join('|');
const schemes = (settings.get('Markdown_SupportSchemesForLink') || '').split(',').join('|');
if (settings.get('Markdown_Headers')) {
// Support # Text for h1

@ -0,0 +1,15 @@
export const isIE11 = () => {
const { userAgent } = window.navigator;
const msieIdx = userAgent.indexOf('MSIE');
if (msieIdx > 0) {
return parseInt(userAgent.substring(msieIdx + 5, userAgent.indexOf('.', msieIdx))) === 11;
}
// If MSIE detection fails, check the Trident engine version
if (navigator.userAgent.match(/Trident\/7\./)) {
return true;
}
return false;
};

@ -0,0 +1 @@
../../../node_modules/@rocket.chat/apps-engine
Loading…
Cancel
Save