From 43858de596bd0eca5c75576ae8005e634a442183 Mon Sep 17 00:00:00 2001 From: Avital Oliver Date: Fri, 21 Feb 2014 17:17:00 -0800 Subject: [PATCH] Improve canonicalizeHTML to support empty attribute on IE8 --- packages/test-helpers/canonicalize_html.js | 8 ++++++-- packages/ui/render_tests.js | 10 +++++----- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/packages/test-helpers/canonicalize_html.js b/packages/test-helpers/canonicalize_html.js index 12021cd804..f4869b7487 100644 --- a/packages/test-helpers/canonicalize_html.js +++ b/packages/test-helpers/canonicalize_html.js @@ -39,8 +39,12 @@ canonicalizeHtml = function(html) { if (! attrList[i]) continue; var a = attrList[i].split('='); - if (a.length < 2) - a.push(a[0]); // things like checked=checked, in theory + + // In IE8, attributes whose value is "" appear + // without the '=' sign altogether. + if (a.length < 2) + a.push(""); + var key = a[0]; // Drop another expando property used by Sizzle. if (key === 'sizset') diff --git a/packages/ui/render_tests.js b/packages/ui/render_tests.js index 4c6abb156f..4142cd55a3 100644 --- a/packages/ui/render_tests.js +++ b/packages/ui/render_tests.js @@ -83,11 +83,11 @@ Tinytest.add("ui - render - basic", function (test) { '
', 'HTML.BR({a: [[""]]})'); - run(BR({ - x: function () { return function () { return []; }; }, - a: function () { return function () { return ''; }; }}), - '
', - '
'); + run(BR({ + x: function () { return function () { return []; }; }, + a: function () { return function () { return ''; }; }}), + '
', + '
'); }); // test that we correctly update the 'value' property on input fields