Commit 74921778 authored by Robert Knight's avatar Robert Knight

Use `annotation` rather than `ann` for consistency

We use both terms to refer to an annotation in various places, but
`annotation` is more common in this module.
parent 5a9fa9d5
...@@ -82,23 +82,24 @@ export default class AnnotationSync { ...@@ -82,23 +82,24 @@ export default class AnnotationSync {
} }
/** /**
* Assign a non-enumerable tag to objects which cross the bridge. * Assign a non-enumerable "tag" to identify annotations exchanged between
* This tag is used to identify the objects between messages. * the sidebar and annotator and associate the tag with the `annotation` instance
* in the local cache.
* *
* @param {AnnotationData} ann * @param {AnnotationData} annotation
* @param {string} [tag] * @param {string} [tag] - The tag to assign
* @return {AnnotationData} * @return {AnnotationData}
*/ */
_tag(ann, tag) { _tag(annotation, tag) {
if (ann.$tag) { if (annotation.$tag) {
return ann; return annotation;
} }
tag = tag || window.btoa(Math.random().toString()); tag = tag || window.btoa(Math.random().toString());
Object.defineProperty(ann, '$tag', { Object.defineProperty(annotation, '$tag', {
value: tag, value: tag,
}); });
this.cache[tag] = ann; this.cache[tag] = annotation;
return ann; return annotation;
} }
/** /**
...@@ -116,15 +117,15 @@ export default class AnnotationSync { ...@@ -116,15 +117,15 @@ export default class AnnotationSync {
/** /**
* Format an annotation into an RPC message body. * Format an annotation into an RPC message body.
* *
* @param {AnnotationData} ann * @param {AnnotationData} annotation
* @return {RpcMessage} * @return {RpcMessage}
*/ */
_format(ann) { _format(annotation) {
this._tag(ann); this._tag(annotation);
return { return {
tag: ann.$tag, tag: annotation.$tag,
msg: ann, msg: annotation,
}; };
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment