wechat-miniprogram / glass-easel

Multiple-backend component-based JavaScript framework
MIT License
240 stars 34 forks source link

Updating array element in object expanded by `wx:for` not working correctly #150

Closed SgLy closed 6 months ago

SgLy commented 6 months ago

Failing test case:

  // core/data_update.test.ts

  test('', () => {
    const compDef = componentSpace
      .define()
      .data(() => ({
        obj: {
          bbb: ['1'],
        },
      }))
      .template(tmpl('<block wx:for="{{obj}}">{{item[0]}}</block>'))
      .registerComponent()

    const comp = glassEasel.Component.createWithContext('root', compDef, domBackend)
    const shadowRoot = comp.shadowRoot as glassEasel.ShadowRoot

    expect(shadowRoot.getComposedChildren()[2]!.asTextNode()!.textContent).toBe('1')

    comp.setData({
      'obj.bbb[0]': '6',
    })

    expect(shadowRoot.getComposedChildren()[2]!.asTextNode()!.textContent).toBe('6')
  })