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

getAnnotations and clearAnnotations use different data structures for empty set. #1253

Closed
NodeGuy opened this issue Feb 16, 2013 · 1 comment

Comments

@NodeGuy
Copy link

NodeGuy commented Feb 16, 2013

getAnnotations returns an array and clearAnnotations uses an object:

/**
* Returns the annotations for the `EditSession`.
* @returns {Object}
**/
this.getAnnotations = function() {
    return this.$annotations || [];
};

/**
* Clears all the annotations for this session. This function also triggers the `'changeAnnotation'` event.
**/
this.clearAnnotations = function() {
    this.$annotations = {};
    this._emit("changeAnnotation", {});
};

This causes an error when trying to add a single new annotation:

session.clearAnnotations();
session.setAnnotations(session.getAnnotations().concat(newAnnotation));

> TypeError: session.getAnnotations(...).concat is not a function
@NodeGuy
Copy link
Author

NodeGuy commented Feb 16, 2013

Thanks for the super-fast fix! After creating the issue I decided to fix it myself, including writing a test case, before I saw your fix. Please consider including my pull request #1257 (rebased on top of your commit).

nightwing added a commit that referenced this issue Feb 16, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants