There's a problem with _commitPromise; because it changes this.value, it will cause all forms of "caching" for other commits to break. Because of this things like the current until directive implementation are really inefficient.
The until directive does this:
part.setValue(defaultContent);
part.commit();
part.setValue(promise);
Imagine that defaultContent is a Node. Right now, the node is removed from DOM and re-inserted every time the directive is processed, because part.setValue(promise) changes part.value which causes the next part.setValue(defaultContent) to fail to detect that it already rendered this node.
This happens regardless if the Promise is resolved or not.
Essentially, _commitPromise breaks the this.value API by setting it to a value that does not represent the currently rendered value, which then breaks the other commit functions that rely on that API.
It can be solved by using a this.promise-like variable and use that instead of this.value for promises.
I can make a PR for this.
There's a problem with
_commitPromise; because it changesthis.value, it will cause all forms of "caching" for other commits to break. Because of this things like the currentuntildirective implementation are really inefficient.The
untildirective does this:Imagine that
defaultContentis aNode. Right now, the node is removed from DOM and re-inserted every time the directive is processed, becausepart.setValue(promise)changespart.valuewhich causes the nextpart.setValue(defaultContent)to fail to detect that it already rendered this node.This happens regardless if the Promise is resolved or not.
Essentially,
_commitPromisebreaks thethis.valueAPI by setting it to a value that does not represent the currently rendered value, which then breaks the other commit functions that rely on that API.It can be solved by using a
this.promise-like variable and use that instead ofthis.valuefor promises.I can make a PR for this.