ilinsky / jquery-xpath

jQuery XPath plugin (with full XPath 2.0 language support)
180 stars 64 forks source link

numeric >= and <= don't work for the equals case #9

Closed jbmercha closed 9 years ago

jbmercha commented 10 years ago

If the following code (and in the >= case) the || operator is always going to return the cXSBoolean object returned by the first call, since it it not a fall like value.

if (fXSAnyAtomicType_isNumeric(oLeft)) {
        if (fXSAnyAtomicType_isNumeric(oRight))
            return hStaticContext_operators["numeric-less-than"].call(oContext, oLeft, oRight) || hStaticContext_operators["numeric-equal"].call(oContext, oLeft, oRight);
    }

Suggest changing it to

if (fXSAnyAtomicType_isNumeric(oLeft)) {
        if (fXSAnyAtomicType_isNumeric(oRight))
            sOperator = "numeric-greater-than";
    }

and letting it fall through like the other cases

ilinsky commented 9 years ago

Can you please suggest a test query which would demonstrate the problem?

ilinsky commented 9 years ago

Test case: 1>=1 and 1<=1 both returning false for numeric types.