Skip to content

_commitPromise is inefficient #451

Description

@ruphin

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions