Skip to content
New issue

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

patch.js文件的一行代码疑惑 #14

Open
jypblue opened this issue Jun 14, 2017 · 2 comments
Open

patch.js文件的一行代码疑惑 #14

jypblue opened this issue Jun 14, 2017 · 2 comments

Comments

@jypblue
Copy link

jypblue commented Jun 14, 2017

阅读patch.js源代码的时候发现这句代码:

      if (staticNodeList[index] === node.childNodes[index]) { // maybe have been removed for inserting
        node.removeChild(node.childNodes[index])
      }

不是很理解,
因为此代码上面做了数组转化赋值:

var staticNodeList = _.toArray(node.childNodes)

不太明白这个条件判断是为啥?

@wangbinyq
Copy link

childNodes 是动态的, 添加删除节点会发生改变

@jypblue
Copy link
Author

jypblue commented Jun 18, 2017

好的,谢谢!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants