From c6e3033b49b002bc89a25abd3f59d39ec7a7c397 Mon Sep 17 00:00:00 2001 From: Dave Olsen Date: Sun, 27 Oct 2013 21:36:18 -0400 Subject: [PATCH] making sure, if embedding annotations, that only one result per found selector appears --- public/styleguide/js/annotations-pattern.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/public/styleguide/js/annotations-pattern.js b/public/styleguide/js/annotations-pattern.js index 0e5d715..06278f3 100644 --- a/public/styleguide/js/annotations-pattern.js +++ b/public/styleguide/js/annotations-pattern.js @@ -50,7 +50,7 @@ var annotationsPattern = { // if an element was clicked on while the overlay was already on swap it obj = { "commentOverlay": "on", "swapOverlay": true, "el": item.el, "title": item.title, "comment": item.comment }; - + } } @@ -178,8 +178,8 @@ var annotationsPattern = { for (comment in comments.comments) { var item = comments.comments[comment]; var els = document.querySelectorAll(item.el); - for (var i = 0; i < els.length; ++i) { - annotationsPattern.embedComments(els[i],item.title,item.comment); + if (els.length > 0) { + annotationsPattern.embedComments(els[0],item.title,item.comment); } annotationsPattern.commentsEmbedded = true; }