We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
const history = new History() const state = { a: 1, b: 2 } history.pushSync({ ...state }) history.pushSync({ ...state, ...{ a: 2 } }) history.pushSync({ ...state, ...{ a: 3 } }); history.undo(); history.undo(); let r1 = history.get(); // { a: 1, b: 2, children: undefined } history.pushSync({ ...state, ...{ c: 1 } }); let r2 = history.get(); let r3 = history.length; // 3 应该等于2 history.undo(); let r4 = history.get(); // { a: 1, b: 2, children: undefined }
存在的几点问题
The text was updated successfully, but these errors were encountered:
@julyL @doodlewind 问题的第二点,我实测应该是对的。
Sorry, something went wrong.
@xiaoluoboding 框架内部通过维护 $records数组和$index 来记录状态 前3次执行pushSync, 内部会向$records存入3个操作,2次undo,改变$index-- 第三次pushSync会将 $record[2]置为null ,pushSync内部代码如下
for (let i = this.$index + 1; i < this.$records.length; i++) { this.$records[i] = null }
第三次pushSync之后,实际上$records里面只存储了2个有效操作 但是length的取值并没有过滤null值
get length() { return Math.min(this.$records.length, this.maxLength) }
谢谢你的定位,近期刚好也有其他维护需求,待我这顺便处理下哈
No branches or pull requests
存在的几点问题
The text was updated successfully, but these errors were encountered: