Skip to content

Commit 854b8ad

Browse files
committed
1 parent b15aa47 commit 854b8ad

9 files changed

Lines changed: 58 additions & 8 deletions

lib/rangy-classapplier.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
* Copyright 2019, Tim Down
1111
* Licensed under the MIT license.
12-
* Version: 1.3.2
12+
* Version: 1.3.3
1313
* Build date: 2 January 2019
1414
*/
1515
(function(factory, root) {

lib/rangy-core.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*
55
* Copyright 2019, Tim Down
66
* Licensed under the MIT license.
7-
* Version: 1.3.2
7+
* Version: 1.3.3
88
* Build date: 2 January 2019
99
*/
1010

@@ -109,7 +109,7 @@
109109
};
110110

111111
var api = {
112-
version: "1.3.2",
112+
version: "1.3.3",
113113
initialized: false,
114114
isBrowser: isBrowser,
115115
supported: true,

lib/rangy-highlighter.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*
77
* Copyright 2019, Tim Down
88
* Licensed under the MIT license.
9-
* Version: 1.3.2
9+
* Version: 1.3.3
1010
* Build date: 2 January 2019
1111
*/
1212
(function(factory, root) {

lib/rangy-selectionsaverestore.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
* Copyright 2019, Tim Down
1111
* Licensed under the MIT license.
12-
* Version: 1.3.2
12+
* Version: 1.3.3
1313
* Build date: 2 January 2019
1414
*/
1515
(function(factory, root) {

lib/rangy-serializer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*
1111
* Copyright 2019, Tim Down
1212
* Licensed under the MIT license.
13-
* Version: 1.3.2
13+
* Version: 1.3.3
1414
* Build date: 2 January 2019
1515
*/
1616
(function(factory, root) {

lib/rangy-textrange.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
*
2727
* Copyright 2019, Tim Down
2828
* Licensed under the MIT license.
29-
* Version: 1.3.2
29+
* Version: 1.3.3
3030
* Build date: 2 January 2019
3131
*/
3232

@@ -1468,6 +1468,13 @@
14681468
currentChar = currentChar.toLowerCase();
14691469
}
14701470

1471+
// If there is a non-breaking space in the innerText, then replace with empty space " " so that it
1472+
// matches with the searchTerm. Based on the documentation, search should be performed on
1473+
// the visible text of the document
1474+
if (currentChar == "\u00a0") {
1475+
currentChar = " ";
1476+
}
1477+
14711478
if (backward) {
14721479
chars.unshift(pos);
14731480
text = currentChar + text;

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "rangy-updated",
33
"description": "A cross-browser DOM range and selection library, cloned from the original rangy repository, updated, and accepting PRs",
4-
"version": "1.3.2",
4+
"version": "1.3.3",
55
"author": {
66
"name": "Patrick Burrows",
77
"email": "pburrows@burrowscorp.com",

src/modules/rangy-textrange.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1530,6 +1530,13 @@ rangy.createModule("TextRange", ["WrappedSelection"], function(api, module) {
15301530
currentChar = currentChar.toLowerCase();
15311531
}
15321532

1533+
// If there is a non-breaking space in the innerText, then replace with empty space " " so that it
1534+
// matches with the searchTerm. Based on the documentation, search should be performed on
1535+
// the visible text of the document
1536+
if (currentChar == "\u00a0") {
1537+
currentChar = " ";
1538+
}
1539+
15331540
if (backward) {
15341541
chars.unshift(pos);
15351542
text = currentChar + text;

test/textrangetests.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -920,6 +920,42 @@ xn.test.suite("Text Range module tests", function(s) {
920920
t.assertFalse(range.findText("Two", options));
921921
});
922922

923+
s.test("findText text with non-breaking space", function(t) {
924+
t.el.innerHTML = 'One Two three';
925+
var textNode = t.el.firstChild;
926+
var range = rangy.createRange();
927+
range.collapseToPoint(textNode, 0);
928+
929+
var scopeRange = rangy.createRange();
930+
scopeRange.selectNodeContents(t.el);
931+
var options = {
932+
withinRange: scopeRange
933+
};
934+
935+
t.assert(range.findText("Two ", options));
936+
testRangeBoundaries(t, range, textNode, 4, textNode, 8);
937+
range.collapse(false);
938+
t.assertFalse(range.findText("Two", options));
939+
});
940+
941+
s.test("findText text with non-breaking space and normal space", function(t) {
942+
t.el.innerHTML = 'One Two  three';
943+
var textNode = t.el.firstChild;
944+
var range = rangy.createRange();
945+
range.collapseToPoint(textNode, 0);
946+
947+
var scopeRange = rangy.createRange();
948+
scopeRange.selectNodeContents(t.el);
949+
var options = {
950+
withinRange: scopeRange
951+
};
952+
953+
t.assert(range.findText("Two three", options));
954+
testRangeBoundaries(t, range, textNode, 4, textNode, 14);
955+
range.collapse(false);
956+
t.assertFalse(range.findText("Two", options));
957+
});
958+
923959
s.test("findText simple text no wrap", function(t) {
924960
t.el.innerHTML = 'Two One Two three';
925961
var textNode = t.el.firstChild;

0 commit comments

Comments
 (0)