Commit 40cef0f6 authored by Robert Knight's avatar Robert Knight Committed by Nick Stenning

Do not render moderation banner if annotation is missing (#369)

Fix exception when rendering a thread if the thread item has no
annotation. This happens if the thread item was created for an
annotation whose prior existence was inferred by a reply but no longer
exists.
parent 99e385b1
......@@ -198,4 +198,18 @@ describe('annotationThread', function () {
.controller('moderationBanner');
assert.deepEqual(moderationBanner, { annotation: ann });
});
it('does not render the annotation or moderation banner if there is no annotation', function () {
var thread = {
annotation: null,
id: '123',
parent: null,
children: [],
};
var element = util.createDirective(document, 'annotationThread', {
thread: thread,
});
assert.notOk(element[0].querySelector('moderation-banner'));
assert.notOk(element[0].querySelector('annotation'));
});
});
......@@ -10,7 +10,8 @@
<div class="annotation-thread__thread-line"></div>
</div>
<div class="annotation-thread__content">
<moderation-banner annotation="vm.thread.annotation">
<moderation-banner annotation="vm.thread.annotation"
ng-if="vm.thread.annotation">
</moderation-banner>
<annotation ng-class="vm.annotationClasses()"
annotation="vm.thread.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