rawmodel/framework

`prop.commit()` sets incorrect `initialValue` for falsy primitive values

dyurkavets opened this issue · 2 comments

import assert from 'assert'
import { Model, prop } from '@rawmodel/core'

class Issue extends Model {
    @prop()
    closed!: boolean

    @prop()
    priority!: number
}

const issue = new Issue({ closed: false, priority: 0 })

issue.commit()

// AssertionError [ERR_ASSERTION]: true == false
assert.equal(
    issue.isChanged(),
    false
)

// AssertionError [ERR_ASSERTION]: { closed: false, priority: 0 } deepEqual {}
assert.deepEqual(
    issue.filter((ref) => ref.prop.isChanged()),
    {}
)

https://github.com/rawmodel/framework/blob/master/packages/rawmodel-core/src/core/props.ts#L358

Thanks! I'll fix this asap.