Skip to content
Snippets Groups Projects
Commit 04856975 authored by Thomas Tanghus's avatar Thomas Tanghus
Browse files

Add compatibility function for outerHTML

parent 1f194b7b
No related branches found
No related tags found
No related merge requests found
......@@ -133,4 +133,18 @@ if(!String.prototype.trim) {
String.prototype.trim = function () {
return this.replace(/^\s+|\s+$/g,'');
};
}
\ No newline at end of file
}
// 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);
}
......@@ -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) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment