Why does cloneNode need to be used when appending a documentFragment?

后端 未结 4 1033
醉酒成梦
醉酒成梦 2021-01-04 22:36

I\'ve been looking at using documentFragments in a Backbone.js app and was wondering why I see examples where \"cloneNode\" is used when appending the documentFragment to th

4条回答
  •  逝去的感伤
    2021-01-04 23:23

    I'm not exactly sure, but in the context of the link you provided (performance testing) the oFrag.cloneNode(true) might be a safeguard against reusing the elements already added in DOM in previous runs of the loop, which would result in way faster execution of the test.

    I see no reason to use it in normal use cases of documentFragments.

提交回复
热议问题