diff options
author | Rick Waldron <waldron.rick@gmail.com> | 2011-05-13 12:26:17 -0400 |
---|---|---|
committer | timmywil <tim.willison@thisismedium.com> | 2011-05-13 12:26:17 -0400 |
commit | ec829431feed29b393b1c22ca97e8af49f47e228 (patch) | |
tree | 6b034477d1269d453b6e28e9bd928cb6aedfc2be /src/manipulation.js | |
parent | a5b7c0fa3316616d86bcb584375b02e33b0bac08 (diff) | |
parent | 0c2d1aee5421b650159116b6bdcb74a4fe96f9ad (diff) | |
download | jquery-ec829431feed29b393b1c22ca97e8af49f47e228.tar.gz jquery-ec829431feed29b393b1c22ca97e8af49f47e228.zip |
Landing pull request 365. jQuery.buildFragment, ensure doc is a document; Fixes #8950.
More Details:
- https://github.com/jquery/jquery/pull/365
- http://bugs.jquery.com/ticket/8950
Diffstat (limited to 'src/manipulation.js')
-rw-r--r-- | src/manipulation.js | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/src/manipulation.js b/src/manipulation.js index 136260450..a148658f5 100644 --- a/src/manipulation.js +++ b/src/manipulation.js @@ -438,8 +438,21 @@ function cloneFixAttributes( src, dest ) { } jQuery.buildFragment = function( args, nodes, scripts ) { - var fragment, cacheable, cacheresults, - doc = (nodes && nodes[0] ? nodes[0].ownerDocument || nodes[0] : document); + var fragment, cacheable, cacheresults, doc; + + // nodes may contain either an explicit document object, + // a jQuery collection or context object. + // If nodes[0] contains a valid object to assign to doc + if ( nodes && nodes[0] ) { + doc = nodes[0].ownerDocument || nodes[0]; + } + + // Ensure that an attr object doesn't incorrectly stand in as a document object + // Chrome and Firefox seem to allow this to occur and will throw exception + // Fixes #8950 + if ( !doc.createDocumentFragment ) { + doc = document; + } // Only cache "small" (1/2 KB) HTML strings that are associated with the main document // Cloning options loses the selected state, so don't cache them @@ -747,4 +760,4 @@ function evalScript( i, elem ) { } } -})( jQuery ); +})( jQuery );
\ No newline at end of file |