Merge pull request #3177 from owncloud/outerHTML_compatibility

Add compatibility function for outerHTML
This commit is contained in:
Thomas Tanghus 2013-05-04 12:27:24 -07:00
commit 83db2c83ad
2 changed files with 16 additions and 2 deletions

View File

@ -133,4 +133,18 @@ if(!String.prototype.trim) {
String.prototype.trim = function () {
return this.replace(/^\s+|\s+$/g,'');
};
}
}
// Older Firefoxes doesn't support outerHTML
// From http://stackoverflow.com/questions/1700870/how-do-i-do-outerhtml-in-firefox#answer-3819589
function outerHTML(node){
// In newer browsers use the internal property otherwise build a wrapper.
return node.outerHTML || (
function(n){
var div = document.createElement('div'), h;
div.appendChild( n.cloneNode(true) );
h = div.innerHTML;
div = null;
return h;
})(node);
}

View File

@ -72,7 +72,7 @@
},
// From stackoverflow.com/questions/1408289/best-way-to-do-variable-interpolation-in-javascript
_build: function(o){
var data = this.elem.attr('type') === 'text/template' ? this.elem.html() : this.elem.get(0).outerHTML;
var data = this.elem.attr('type') === 'text/template' ? this.elem.html() : outerHTML(this.elem.get(0));
try {
return data.replace(/{([^{}]*)}/g,
function (a, b) {