Permalink
Browse files

Fix `PxLoaderTags#contains` when comparing tag arrays with one element

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...
1 parent 97a63c4 commit 73628dc6be2d2e7b814ed42c29c7fc07e06c499c @leolannenmaki leolannenmaki committed Jul 30, 2012
Showing with 1 addition and 1 deletion.
  1. +1 −1 PxLoader.js
View
@@ -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 {

0 comments on commit 73628dc

Please sign in to comment.