this is related to some changes made as part of #9948
what do you think about making a change to the batching so that if you call openBatch
a number of times, the extracted contents aren't placed back in the document until a matching number of closeBatch
calls are made? currently, the first call to closeBatch
will put the contents back in the document. my suggestion is something like this:
_init: function(){
gs.Container._init.call(this);
this._batch = 0;
},
openBatch: function() {
// summary: starts a new batch, subsequent new child shapes will be held in
// the batch instead of appending to the container directly
this.fragment = _createFragment();
this._batch++;
},
closeBatch: function() {
// summary: submits the current batch, append all pending child shapes to DOM
this._batch = this._batch > 0 ? this._batch-- : 0;
if (this.fragment && !this._batch) {
this.rawNode.appendChild(this.fragment);
delete this.fragment;
}
},
currently code like this pseudo-code won't be as optimized as it could be:
changeSomething: function () {
this.surface.openBatch();
if(someCondition){
this.changeAnother();
}
// update stuff that doesn't depend on someCondition
this.surface.closeBatch();
},
changeAnother: function () {
this.surface.openBatch();
// update some other stuff
this.surface.closeBatch();
}
the batch is closed after the call to this.changeAnother()
and the rest of the updates in changeSomething
aren't "batched".
Yes, we definitely need this functionality.