Comparing version 2.3.0 to 2.3.1
@@ -28,3 +28,4 @@ { | ||
"serializable", "tis", "twas", "int", "args", "unshift", "plugins", "upsert", | ||
"upserting", "readonly", "baz", "tokenization", "lunrjs", "com" | ||
"upserting", "readonly", "baz", "tokenization", "lunrjs", "com", "olivernn", | ||
"github", "js" | ||
] | ||
@@ -31,0 +32,0 @@ } |
# Changelog | ||
## 2.3.1 | ||
* Add workaround for inconsistent browser behaviour [#279](https://github.com/olivernn/lunr.js/issues/279), thanks [Luca Ongaro](https://github.com/lucaong). | ||
* Fix bug in intersect/union of `lunr.Set` [#360](https://github.com/olivernn/lunr.js/issues/360), thanks [Brandon Bethke](https://github.com/brandon-bethke-neudesic) for reporting. | ||
## 2.3.0 | ||
@@ -4,0 +9,0 @@ |
@@ -88,2 +88,10 @@ /*! | ||
if (other === lunr.Set.complete) { | ||
return this | ||
} | ||
if (other === lunr.Set.empty) { | ||
return other | ||
} | ||
if (this.length < other.length) { | ||
@@ -117,3 +125,11 @@ a = this | ||
lunr.Set.prototype.union = function (other) { | ||
if (other === lunr.Set.complete) { | ||
return lunr.Set.complete | ||
} | ||
if (other === lunr.Set.empty) { | ||
return this | ||
} | ||
return new lunr.Set(Object.keys(this.elements).concat(Object.keys(other.elements))) | ||
} |
@@ -302,2 +302,7 @@ /*! | ||
if (frame.node.final) { | ||
/* In Safari, at this point the prefix is sometimes corrupted, see: | ||
* https://github.com/olivernn/lunr.js/issues/279 Calling any | ||
* String.prototype method forces Safari to "cast" this string to what | ||
* it's supposed to be, fixing the bug. */ | ||
frame.prefix.charAt(0) | ||
words.push(frame.prefix) | ||
@@ -304,0 +309,0 @@ } |
{ | ||
"name": "lunr", | ||
"description": "Simple full-text search in your browser.", | ||
"version": "2.3.0", | ||
"version": "2.3.1", | ||
"author": "Oliver Nightingale", | ||
@@ -6,0 +6,0 @@ "keywords": ["search"], |
@@ -1033,2 +1033,29 @@ suite('search', function () { | ||
}) | ||
suite('different fields one without match', function () { | ||
var assertions = function () { | ||
test('no matches', function () { | ||
assert.lengthOf(this.results, 0) | ||
}) | ||
} | ||
suite('#search', function () { | ||
setup(function () { | ||
this.results = this.idx.search('+title:plant +body:qwertyuiop') | ||
}) | ||
assertions() | ||
}) | ||
suite('#query', function () { | ||
setup(function () { | ||
this.results = this.idx.query(function (q) { | ||
q.term('plant', { fields: ['title'], presence: lunr.Query.presence.REQUIRED }) | ||
q.term('qwertyuiop', { fields: ['body'], presence: lunr.Query.presence.REQUIRED }) | ||
}) | ||
}) | ||
assertions() | ||
}) | ||
}) | ||
}) | ||
@@ -1035,0 +1062,0 @@ |
@@ -50,10 +50,33 @@ suite('lunr.Set', function () { | ||
suite('populated set', function () { | ||
test('contains both elements', function () { | ||
var target = new lunr.Set (['bar']) | ||
var result = target.union(this.set) | ||
suite('with other populated set', function () { | ||
test('contains both elements', function () { | ||
var target = new lunr.Set (['bar']) | ||
var result = target.union(this.set) | ||
assert.isOk(result.contains('foo')) | ||
assert.isOk(result.contains('bar')) | ||
assert.isNotOk(result.contains('baz')) | ||
assert.isOk(result.contains('foo')) | ||
assert.isOk(result.contains('bar')) | ||
assert.isNotOk(result.contains('baz')) | ||
}) | ||
}) | ||
suite('with empty set', function () { | ||
test('contains all elements', function () { | ||
var target = new lunr.Set (['bar']) | ||
var result = target.union(lunr.Set.empty) | ||
assert.isOk(result.contains('bar')) | ||
assert.isNotOk(result.contains('baz')) | ||
}) | ||
}) | ||
suite('with complete set', function () { | ||
test('contains all elements', function () { | ||
var target = new lunr.Set (['bar']) | ||
var result = target.union(lunr.Set.complete) | ||
assert.isOk(result.contains('foo')) | ||
assert.isOk(result.contains('bar')) | ||
assert.isOk(result.contains('baz')) | ||
}) | ||
}) | ||
}) | ||
@@ -101,4 +124,22 @@ }) | ||
}) | ||
suite('with empty set', function () { | ||
test('returns empty set', function () { | ||
var target = new lunr.Set(['foo']), | ||
result = target.intersect(lunr.Set.empty) | ||
assert.isNotOk(result.contains('foo')) | ||
}) | ||
}) | ||
suite('with complete set', function () { | ||
test('returns populated set', function () { | ||
var target = new lunr.Set(['foo']), | ||
result = target.intersect(lunr.Set.complete) | ||
assert.isOk(result.contains('foo')) | ||
}) | ||
}) | ||
}) | ||
}) | ||
}) |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
937090
28473