Fix bug, add tests to catch it
authorAryeh Gregor <AryehGregor+gitcommit@gmail.com>
Sun, 05 Jun 2011 15:17:27 -0600
changeset 228 7bd750edd8a1
parent 227 6c96ab178ca6
child 229 c77b3c2f5c08
Fix bug, add tests to catch it

Bug reported by Tim Down by e-mail.
autoimplementation.html
implementation.js
--- a/autoimplementation.html	Fri Jun 03 15:20:13 2011 -0600
+++ b/autoimplementation.html	Sun Jun 05 15:17:27 2011 -0600
@@ -1556,6 +1556,25 @@
 		'<div style=text-align:right><p>[foo]<p>bar</div><p>extra',
 		'<div style=text-align:right><p>[foo<p>bar]</div><p>extra',
 
+		'<center>foo</center>[bar]<p>extra',
+		'[foo]<center>bar</center><p>extra',
+		'<center>foo</center>[bar]<center>baz</center><p>extra',
+		'<div align=center>foo</div>[bar]<p>extra',
+		'[foo]<div align=center>bar</div><p>extra',
+		'<div align=center>foo</div>[bar]<div align=center>baz</div><p>extra',
+		'<div align=center><p>foo</div><p>[bar]<p>extra',
+		'<p>[foo]<div align=center><p>bar</div><p>extra',
+		'<div align=center><p>foo</div><p>[bar]<div align=center><p>baz</div><p>extra',
+		'<div style=text-align:center>foo</div>[bar]<p>extra',
+		'[foo]<div style=text-align:center>bar</div><p>extra',
+		'<div style=text-align:center>foo</div>[bar]<div style=text-align:center>baz</div><p>extra',
+		'<div style=text-align:center><p>foo</div><p>[bar]<p>extra',
+		'<p>[foo]<div style=text-align:center><p>bar</div><p>extra',
+		'<div style=text-align:center><p>foo</div><p>[bar]<div style=text-align:center><p>baz</div><p>extra',
+		'<p align=center>foo<p>[bar]<p>extra',
+		'<p>[foo]<p align=center>bar<p>extra',
+		'<p align=center>foo<p>[bar]<p align=center>baz<p>extra',
+
 		'<div align=nonsense><p>[foo]</div><p>extra',
 		'<div style=text-align:inherit><p>[foo]</div><p>extra',
 		'<quasit align=right><p>[foo]</p></quasit><p>extra',
@@ -1595,6 +1614,22 @@
 		'<div style=text-align:right><p>[foo]<p>bar</div><p>extra',
 		'<div style=text-align:right><p>[foo<p>bar]</div><p>extra',
 
+		'<div align=justify>foo</div>[bar]<p>extra',
+		'[foo]<div align=justify>bar</div><p>extra',
+		'<div align=justify>foo</div>[bar]<div align=justify>baz</div><p>extra',
+		'<div align=justify><p>foo</div><p>[bar]<p>extra',
+		'<p>[foo]<div align=justify><p>bar</div><p>extra',
+		'<div align=justify><p>foo</div><p>[bar]<div align=justify><p>baz</div><p>extra',
+		'<div style=text-align:justify>foo</div>[bar]<p>extra',
+		'[foo]<div style=text-align:justify>bar</div><p>extra',
+		'<div style=text-align:justify>foo</div>[bar]<div style=text-align:justify>baz</div><p>extra',
+		'<div style=text-align:justify><p>foo</div><p>[bar]<p>extra',
+		'<p>[foo]<div style=text-align:justify><p>bar</div><p>extra',
+		'<div style=text-align:justify><p>foo</div><p>[bar]<div style=text-align:justify><p>baz</div><p>extra',
+		'<p align=justify>foo<p>[bar]<p>extra',
+		'<p>[foo]<p align=justify>bar<p>extra',
+		'<p align=justify>foo<p>[bar]<p align=justify>baz<p>extra',
+
 		'<div align=nonsense><p>[foo]</div><p>extra',
 		'<div style=text-align:inherit><p>[foo]</div><p>extra',
 		'<quasit align=center><p>[foo]</p></quasit><p>extra',
@@ -1634,6 +1669,22 @@
 		'<div style=text-align:right><p>[foo]<p>bar</div><p>extra',
 		'<div style=text-align:right><p>[foo<p>bar]</div><p>extra',
 
+		'<div align=left>foo</div>[bar]<p>extra',
+		'[foo]<div align=left>bar</div><p>extra',
+		'<div align=left>foo</div>[bar]<div align=left>baz</div><p>extra',
+		'<div align=left><p>foo</div><p>[bar]<p>extra',
+		'<p>[foo]<div align=left><p>bar</div><p>extra',
+		'<div align=left><p>foo</div><p>[bar]<div align=left><p>baz</div><p>extra',
+		'<div style=text-align:left>foo</div>[bar]<p>extra',
+		'[foo]<div style=text-align:left>bar</div><p>extra',
+		'<div style=text-align:left>foo</div>[bar]<div style=text-align:left>baz</div><p>extra',
+		'<div style=text-align:left><p>foo</div><p>[bar]<p>extra',
+		'<p>[foo]<div style=text-align:left><p>bar</div><p>extra',
+		'<div style=text-align:left><p>foo</div><p>[bar]<div style=text-align:left><p>baz</div><p>extra',
+		'<p align=left>foo<p>[bar]<p>extra',
+		'<p>[foo]<p align=left>bar<p>extra',
+		'<p align=left>foo<p>[bar]<p align=left>baz<p>extra',
+
 		'<div align=nonsense><p>[foo]</div><p>extra',
 		'<div style=text-align:inherit><p>[foo]</div><p>extra',
 		'<quasit align=center><p>[foo]</p></quasit><p>extra',
@@ -1673,6 +1724,22 @@
 		'<div style=text-align:right><p>[foo]<p>bar</div><p>extra',
 		'<div style=text-align:right><p>[foo<p>bar]</div><p>extra',
 
+		'<div align=right>foo</div>[bar]<p>extra',
+		'[foo]<div align=right>bar</div><p>extra',
+		'<div align=right>foo</div>[bar]<div align=right>baz</div><p>extra',
+		'<div align=right><p>foo</div><p>[bar]<p>extra',
+		'<p>[foo]<div align=right><p>bar</div><p>extra',
+		'<div align=right><p>foo</div><p>[bar]<div align=right><p>baz</div><p>extra',
+		'<div style=text-align:right>foo</div>[bar]<p>extra',
+		'[foo]<div style=text-align:right>bar</div><p>extra',
+		'<div style=text-align:right>foo</div>[bar]<div style=text-align:right>baz</div><p>extra',
+		'<div style=text-align:right><p>foo</div><p>[bar]<p>extra',
+		'<p>[foo]<div style=text-align:right><p>bar</div><p>extra',
+		'<div style=text-align:right><p>foo</div><p>[bar]<div style=text-align:right><p>baz</div><p>extra',
+		'<p align=right>foo<p>[bar]<p>extra',
+		'<p>[foo]<p align=right>bar<p>extra',
+		'<p align=right>foo<p>[bar]<p align=right>baz<p>extra',
+
 		'<div align=nonsense><p>[foo]</div><p>extra',
 		'<div style=text-align:inherit><p>[foo]</div><p>extra',
 		'<quasit align=center><p>[foo]</p></quasit><p>extra',
--- a/implementation.js	Fri Jun 03 15:20:13 2011 -0600
+++ b/implementation.js	Sun Jun 05 15:17:27 2011 -0600
@@ -4623,7 +4623,7 @@
 		wrap(sublist,
 			function(node) {
 				return isHtmlElement(node, "div")
-					&& div.attributes.every(function(attr) {
+					&& [].every.call(node.attributes, function(attr) {
 						return (attr.name == "align" && attr.value.toLowerCase() == alignment)
 							|| (attr.name == "style" && node.style.length == 1 && node.style.textAlign == alignment);
 					});