diff --git a/src/ngSanitize/sanitize.js b/src/ngSanitize/sanitize.js
index 50210fea05c1..a23fc1b12e3f 100644
--- a/src/ngSanitize/sanitize.js
+++ b/src/ngSanitize/sanitize.js
@@ -413,7 +413,6 @@ function htmlParser(html, handler) {
}
var hiddenPre=document.createElement("pre");
-var spaceRe = /^(\s*)([\s\S]*?)(\s*)$/;
/**
* decodes all entities into regular string
* @param value
@@ -422,22 +421,10 @@ var spaceRe = /^(\s*)([\s\S]*?)(\s*)$/;
function decodeEntities(value) {
if (!value) { return ''; }
- // Note: IE8 does not preserve spaces at the start/end of innerHTML
- // so we must capture them and reattach them afterward
- var parts = spaceRe.exec(value);
- var spaceBefore = parts[1];
- var spaceAfter = parts[3];
- var content = parts[2];
- if (content) {
- hiddenPre.innerHTML=content.replace(/&c');
});
- it('should use innerText if textContent is not available (IE<9)', function() {
- window.hiddenPre = {
- innerText: 'INNER_TEXT'
- };
- inject(function($sanitize) {
- htmlParser('text', handler);
- expect(text).toEqual('INNER_TEXT');
- });
- });
- it('should use textContent if available', function() {
- window.hiddenPre = {
- textContent: 'TEXT_CONTENT',
- innerText: 'INNER_TEXT'
- };
- inject(function($sanitize) {
- htmlParser('text', handler);
- expect(text).toEqual('TEXT_CONTENT');
- });
- });
- it('should use textContent even if empty', function() {
- window.hiddenPre = {
- textContent: '',
- innerText: 'INNER_TEXT'
- };
- inject(function($sanitize) {
- htmlParser('text', handler);
- expect(text).toEqual('');
- });
+ it('should preserve whitespace', function() {
+ htmlParser(' a&b ', handler)
+ expect(text).toEqual(' a&b ');
});
});