From 0a5603f8bc31c76012bf25e3657cb6f908f3bae1 Mon Sep 17 00:00:00 2001 From: Matthew Findley Date: Tue, 12 May 2015 10:00:12 -0700 Subject: [PATCH] fix(codepen): escape ampersand in   Closes #2827. Fixes #2826. Without escaping the ampersand the   is translated into the incorrect character. --- docs/app/js/codepen.js | 1 + docs/spec/codepen.spec.js | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/docs/app/js/codepen.js b/docs/app/js/codepen.js index 7e12f6b46d9..68182b4d41c 100644 --- a/docs/app/js/codepen.js +++ b/docs/app/js/codepen.js @@ -142,6 +142,7 @@ function htmlEscapeAmpersand(html) { return html .replace(/>/g, "&gt;") + .replace(/ /g, "&nbsp;") .replace(/</g, "&lt;"); } diff --git a/docs/spec/codepen.spec.js b/docs/spec/codepen.spec.js index d31cfd4b0a1..6c6929f6943 100644 --- a/docs/spec/codepen.spec.js +++ b/docs/spec/codepen.spec.js @@ -118,6 +118,15 @@ describe('CodepenDataAdapter', function() { }); + describe('when the html example includes  ', function() { + + it('escapes the ampersand, so that the codepen does not translate to an invalid character', function() { + demo.files.index.contents = '
  
'; + data = codepenDataAdapter.translate(demo, externalScripts); + expect(angular.element(data.html).html()).toBe('&nbsp;&nbsp;'); + }); + }); + describe('when the module definition in the js file is formatted in different ways', function() { it('handles second argument on a new line', function() {