Skip to content

Commit

Permalink
Fix PxLoaderTags#contains when comparing tag arrays with one element
Browse files Browse the repository at this point in the history
The problem is:
    new PxLoaderTags('tag').contains(new PxLoaderTags('tag2')) ==> false
    new PxLoaderTags(['tag1']).contains(new PxLoaderTags(['tag2'])) ==> true

This happens because `contains` checks if the length of both arrays is one and
if this is the case it tries to compare the supposed singular value from both.
This then results in comparing null against null and then returning true, incorrectly.
  • Loading branch information
leolannenmaki committed Jul 30, 2012
1 parent 97a63c4 commit 73628dc
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion PxLoader.js
Expand Up @@ -349,7 +349,7 @@ function PxLoaderTags(values) {
this.contains = function(other) {
if (this.length === 0 || other.length === 0) {
return false;
} else if (this.length === 1) {
} else if (this.length === 1 && this.value !== null) {
if (other.length === 1) {
return this.value === other.value;
} else {
Expand Down

0 comments on commit 73628dc

Please sign in to comment.