Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed property access where a property didnt exist

  • Loading branch information...
commit 8e9ff3b19922ff0ee86973c64e591b0460abbb7b 1 parent 1635109
@DamonOehlman authored
View
4 pkg/amd/matchme.js
@@ -234,7 +234,7 @@ define('matchme', [], function() {
var props = prop.split('.');
if (props.length > 1) {
value = this.target;
- while (props.length) {
+ while (value && props.length) {
value = value[props.shift()];
}
}
@@ -276,7 +276,7 @@ define('matchme', [], function() {
opts = query;
query = array;
array = null;
- };
+ }
// create the matcher on a null target
matcher = new Matcher(null, opts);
View
4 pkg/cjs/matchme.js
@@ -233,7 +233,7 @@ Matcher.prototype = {
var props = prop.split('.');
if (props.length > 1) {
value = this.target;
- while (props.length) {
+ while (value && props.length) {
value = value[props.shift()];
}
}
@@ -275,7 +275,7 @@ matchme.filter = function(array, query, opts) {
opts = query;
query = array;
array = null;
- };
+ }
// create the matcher on a null target
matcher = new Matcher(null, opts);
View
4 pkg/oldschool/matchme.js
@@ -234,7 +234,7 @@
var props = prop.split('.');
if (props.length > 1) {
value = this.target;
- while (props.length) {
+ while (value && props.length) {
value = value[props.shift()];
}
}
@@ -276,7 +276,7 @@
opts = query;
query = array;
array = null;
- };
+ }
// create the matcher on a null target
matcher = new Matcher(null, opts);
View
4 pkg/raw/matchme.js
@@ -233,7 +233,7 @@ Matcher.prototype = {
var props = prop.split('.');
if (props.length > 1) {
value = this.target;
- while (props.length) {
+ while (value && props.length) {
value = value[props.shift()];
}
}
@@ -275,7 +275,7 @@ matchme.filter = function(array, query, opts) {
opts = query;
query = array;
array = null;
- };
+ }
// create the matcher on a null target
matcher = new Matcher(null, opts);
View
2  src/core/matcher.js
@@ -233,7 +233,7 @@ Matcher.prototype = {
var props = prop.split('.');
if (props.length > 1) {
value = this.target;
- while (props.length) {
+ while (value && props.length) {
value = value[props.shift()];
}
}
View
2  src/matchme.js
@@ -32,7 +32,7 @@ matchme.filter = function(array, query, opts) {
opts = query;
query = array;
array = null;
- };
+ }
// create the matcher on a null target
matcher = new Matcher(null, opts);
View
1  test/browser/index.html
@@ -36,6 +36,7 @@
<script src="../logicalprop.js"></script>
<script src="../regex.js"></script>
<script src="../safety.js"></script>
+ <script src="../nested.js"></script>
<script>
$(function () {
mocha.run();
View
5 test/nested.js
@@ -7,4 +7,9 @@ describe('nested property access', function() {
var result = matchme(testdata.location1, 'area.name == Brisbane');
expect(result).to.be.ok();
});
+
+ it('deals with properties that dont exist gracefully', function() {
+ var result = matchme(testdata.location1, 'area.size > 500');
+ expect(result).to.not.be.ok();
+ });
});
Please sign in to comment.
Something went wrong with that request. Please try again.