harttle / liquidjs

A simple, expressive, safe and Shopify compatible template engine in pure JavaScript.
https://liquidjs.com
MIT License
1.52k stars 238 forks source link

IF statements currently do not respond to Drop's valueOf #522

Closed maiyuanrdt closed 2 years ago

maiyuanrdt commented 2 years ago

When comparing two Drop objects using an if statement, the results of valueOf are not compared. Will cause this judgment logic to be false all the time. Refer to the address and AddresDrop objects in Shopify, and compare them according to the valueOf result.

Javascript:

class AddressDrop extends Drop {
    constructor() {
        super()
    }

    valueOf() {
        return 'test'
    }
}

const address = new AddressDrop()
const customer = {
    default_address: new AddressDrop()
}

HTML:

{%- if address == customer.default_address -%}
  <h2>{{ 'customer.addresses.default' | t }}</h2>
{%- endif -%}
github-actions[bot] commented 2 years ago

:tada: This issue has been resolved in version 9.39.2 :tada:

The release is available on:

Your semantic-release bot :package::rocket: