Clicking anywhere should dismiss comments
authorAryeh Gregor <AryehGregor+gitcommit@gmail.com>
Mon, 29 Aug 2011 13:24:16 -0600
changeset 551 c1c9160a162f
parent 550 cd77b203cb6f
child 552 bfb0c735c728
Clicking anywhere should dismiss comments

Reported-By: Ehsan Akhgari
Report-URL: https://github.com/ayg/editing/pull/2
editing.html
source.html
--- a/editing.html	Mon Aug 29 13:02:24 2011 -0600
+++ b/editing.html	Mon Aug 29 13:24:16 2011 -0600
@@ -65,7 +65,7 @@
 <body class=draft>
 <div class=head id=head>
 <h1>HTML Editing APIs</h1>
-<h2 class="no-num no-toc" id=work-in-progress-&mdash;-last-update-28-august-2011>Work in Progress &mdash; Last Update 28 August 2011</h2>
+<h2 class="no-num no-toc" id=work-in-progress-&mdash;-last-update-29-august-2011>Work in Progress &mdash; Last Update 29 August 2011</h2>
 <dl>
  <dt>Editor
  <dd>Aryeh Gregor &lt;<a href=mailto:ayg@aryeh.name>ayg@aryeh.name</a>&gt;
@@ -9044,6 +9044,14 @@
   wrapper.appendChild(button);
   wrapper.appendChild(node);
 });
+document.body.onclick = function(e) {
+  [].forEach.call(document.querySelectorAll(".comments-expanded"), function(node) {
+    if (e.target != node.parentNode
+    && !(e.target.compareDocumentPosition(node.parentNode) & Node.DOCUMENT_POSITION_CONTAINS)) {
+      node.className = "comments";
+    }
+  });
+};
 
 </script>
 <script src=http://www.whatwg.org/specs/web-apps/current-work/dfn.js></script>
--- a/source.html	Mon Aug 29 13:02:24 2011 -0600
+++ b/source.html	Mon Aug 29 13:24:16 2011 -0600
@@ -9123,6 +9123,14 @@
   wrapper.appendChild(button);
   wrapper.appendChild(node);
 });
+document.body.onclick = function(e) {
+  [].forEach.call(document.querySelectorAll(".comments-expanded"), function(node) {
+    if (e.target != node.parentNode
+    && !(e.target.compareDocumentPosition(node.parentNode) & Node.DOCUMENT_POSITION_CONTAINS)) {
+      node.className = "comments";
+    }
+  });
+};
 <!-- @} -->
 </script>
 <script src=http://www.whatwg.org/specs/web-apps/current-work/dfn.js></script>