diff options
author | John Resig <jeresig@gmail.com> | 2009-09-15 16:46:15 +0000 |
---|---|---|
committer | John Resig <jeresig@gmail.com> | 2009-09-15 16:46:15 +0000 |
commit | fc4c6915344625fadf55ca25d3cf9094544d301a (patch) | |
tree | 3e66ff7bd54040425c1875f642100609633887e0 /src/manipulation.js | |
parent | cf8c1249d1efbdaf4f4dd8d1a36bb803335f4ee8 (diff) | |
download | jquery-fc4c6915344625fadf55ca25d3cf9094544d301a.tar.gz jquery-fc4c6915344625fadf55ca25d3cf9094544d301a.zip |
Adding some fixes for commit [6537]. If there's leading whitespace, or if an exception is thrown by innerHTML, we need to use the old style method.
Diffstat (limited to 'src/manipulation.js')
-rw-r--r-- | src/manipulation.js | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/src/manipulation.js b/src/manipulation.js index b88356719..2a1e9237f 100644 --- a/src/manipulation.js +++ b/src/manipulation.js @@ -189,15 +189,21 @@ jQuery.fn.extend({ // See if we can take a shortcut and just use innerHTML } else if ( typeof value === "string" && !/<script/i.test( value ) && - this[0] && !jQuery.isXMLDoc( this[0] ) && + (!jQuery.support.leadingWhitespace || !rleadingWhitespace.test( value )) && !wrapMap[ (rtagName.exec( value ) || ["", ""])[1].toLowerCase() ] ) { - for ( var i = 0, l = this.length; i < l; i++ ) { - // Remove element nodes and prevent memory leaks - if ( this[i].nodeType === 1 ) { - cleanData( this[i].getElementsByTagName("*") ); - this[i].innerHTML = value; + try { + for ( var i = 0, l = this.length; i < l; i++ ) { + // Remove element nodes and prevent memory leaks + if ( this[i].nodeType === 1 ) { + cleanData( this[i].getElementsByTagName("*") ); + this[i].innerHTML = value; + } } + + // If using innerHTML throws an exception, use the fallback method + } catch(e) { + this.empty().append( value ); } } else { |