Don't allow markers to disrupt layout
authorAryeh Gregor <AryehGregor+gitcommit@gmail.com>
Wed, 17 Aug 2011 11:52:09 -0600
changeset 533 2ce6c2981036
parent 532 12ae54979917
child 534 11c5d9a0308f
Don't allow markers to disrupt layout

This makes them overtype on text sometimes, which isn't pretty, but it
ensures they don't add extra line breaks or anything.
tests.js
--- a/tests.js	Wed Aug 17 09:02:44 2011 -0600
+++ b/tests.js	Wed Aug 17 11:52:09 2011 -0600
@@ -3934,6 +3934,7 @@
 	if (msg !== null) {
 		inputCell.lastChild.textContent += " (" + msg + ")";
 	}
+
 	tr.appendChild(inputCell);
 }
 //@}
@@ -4165,10 +4166,10 @@
 	}
 	tr.appendChild(sameCell);
 
-	// Insert <wbr> so IE doesn't stretch the screen.  This is considerably
-	// more complicated than it has to be, thanks to Firefox's lack of support
-	// for outerHTML.
 	for (var i = 0; i <= 2; i++) {
+		// Insert <wbr> so IE doesn't stretch the screen.  This is considerably
+		// more complicated than it has to be, thanks to Firefox's lack of
+		// support for outerHTML.
 		try {
 			var div = tr.childNodes[i].lastChild;
 			var text = div.firstChild.textContent;
@@ -4184,6 +4185,20 @@
 			}
 			div.removeChild(div.firstChild);
 		} catch (e) {};
+
+		// Add position: absolute span to not affect vertical layout
+		getDescendants(tr.childNodes[i].firstChild)
+		.filter(function(node) {
+			return node.nodeType == Node.TEXT_NODE
+				&& /^(\{\}?|\})$/.test(node.data);
+		}).forEach(function(node) {
+			var span = document.createElement("span");
+			span.style.position = "absolute";
+			span.style.outline = "1px solid invert";
+			span.textContent = node.data;
+			node.parentNode.insertBefore(span, node);
+			node.parentNode.removeChild(node);
+		});
 	}
 }
 //@}