app/assets/javascripts/angular/angular-sanitize.js in angular-rails-engine-1.2.3.0 vs app/assets/javascripts/angular/angular-sanitize.js in angular-rails-engine-1.2.5.0
- old
+ new
@@ -1,7 +1,7 @@
/**
- * @license AngularJS v1.2.3
+ * @license AngularJS v1.2.5
* (c) 2010-2014 Google, Inc. http://angularjs.org
* License: MIT
*/
(function(window, angular, undefined) {'use strict';
@@ -363,28 +363,35 @@
stack.length = pos;
}
}
}
+var hiddenPre=document.createElement("pre");
+var spaceRe = /^(\s*)([\s\S]*?)(\s*)$/;
/**
* decodes all entities into regular string
* @param value
* @returns {string} A string with decoded entities.
*/
-var hiddenPre=document.createElement("pre");
function decodeEntities(value) {
- if (!value) {
- return '';
- }
+ if (!value) { return ''; }
+
// Note: IE8 does not preserve spaces at the start/end of innerHTML
- var spaceRe = /^(\s*)([\s\S]*?)(\s*)$/;
+ // so we must capture them and reattach them afterward
var parts = spaceRe.exec(value);
- parts[0] = '';
- if (parts[2]) {
- hiddenPre.innerHTML=parts[2].replace(/</g,"<");
- parts[2] = hiddenPre.innerText || hiddenPre.textContent;
+ var spaceBefore = parts[1];
+ var spaceAfter = parts[3];
+ var content = parts[2];
+ if (content) {
+ hiddenPre.innerHTML=content.replace(/</g,"<");
+ // innerText depends on styling as it doesn't display hidden elements.
+ // Therefore, it's better to use textContent not to cause unnecessary
+ // reflows. However, IE<9 don't support textContent so the innerText
+ // fallback is necessary.
+ content = 'textContent' in hiddenPre ?
+ hiddenPre.textContent : hiddenPre.innerText;
}
- return parts.join('');
+ return spaceBefore + content + spaceAfter;
}
/**
* Escapes all potentially dangerous characters, so that the
* resulting string can be safely inserted into attribute or