Revert "FIX: word boundary regex (\b) not working in Unicode languages. (#9163)"

Lookbehind regex is not supported in Firefox or IE11

This reverts commit 572bb5988f.
This commit is contained in:
David Taylor
2020-03-25 14:34:45 +00:00
parent 9521a88984
commit d62d258fe5
14 changed files with 171 additions and 175 deletions

View File

@@ -94,7 +94,7 @@ QUnit.test("Search with context", async assert => {
const highlighted = [];
find("#post_7 span.highlighted").map((_, span) => {
find("#post_7 span.highlight-strong").map((_, span) => {
highlighted.push(span.innerText);
});

View File

@@ -1,48 +0,0 @@
import highlightSearch, { CLASS_NAME } from "discourse/lib/highlight-search";
import { fixture } from "helpers/qunit-helpers";
QUnit.module("lib:highlight-search");
QUnit.test("highlighting text", assert => {
fixture().html(
`
<p>This is some text to highlight</p>
`
);
highlightSearch(fixture(), "some text");
const terms = [];
fixture(`.${CLASS_NAME}`).each((_, elem) => {
terms.push(elem.textContent);
});
assert.equal(
terms.join(" "),
"some text",
"it should highlight the terms correctly"
);
});
QUnit.test("highlighting unicode text", assert => {
fixture().html(
`
<p>This is some தமிழ் and русский text to highlight</p>
`
);
highlightSearch(fixture(), "தமிழ் русский");
const terms = [];
fixture(`.${CLASS_NAME}`).each((_, elem) => {
terms.push(elem.textContent);
});
assert.equal(
terms.join(" "),
"தமிழ் русский",
"it should highlight the terms correctly"
);
});

View File

@@ -0,0 +1,26 @@
import highlightText, { CLASS_NAME } from "discourse/lib/highlight-text";
import { fixture } from "helpers/qunit-helpers";
QUnit.module("lib:highlight-text");
QUnit.test("highlighting text", assert => {
fixture().html(
`
<p>This is some text to highlight</p>
`
);
highlightText(fixture(), "some text");
const terms = [];
fixture(`.${CLASS_NAME}`).each((_, elem) => {
terms.push(elem.textContent);
});
assert.equal(
terms.join(" "),
"some text",
"it should highlight the terms correctly"
);
});