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

Fails when promiseGetter returns null #2

Closed
green3g opened this issue Jul 24, 2017 · 0 comments · Fixed by #3
Closed

Fails when promiseGetter returns null #2

green3g opened this issue Jul 24, 2017 · 0 comments · Fixed by #3
Assignees
Labels

Comments

@green3g
Copy link

green3g commented Jul 24, 2017

These lines fail https://github.com/canjs/can-stache-key/blob/master/can-stache-key.js#L190-L192

when a promise getter returns null, because typeof null is 'object' and null.then causes an error.

Example, I might not want to return a promise when there is no id to view, so I return null:

    focusObjectPromise: {
        get () {
            if (this.viewId) {
                const params = {};
                params[this.view.connection.idProp] = this.viewId;
                const promise = this.view.connection.get(params);

                promise.catch((err) => {
                    dev.warn('unable to complete focusObject request', err);
                });

                return promise;
            }
            return null;
        }
    },
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants