Core: re-introduce createHTMLDocument in parseHTML; Safari 8 left out

Close gh-1505
This commit is contained in:
Timmy Willison
2014-12-10 09:48:55 -05:00
parent 8653068dd6
commit cfe468f29c
5 changed files with 67 additions and 6 deletions

View File

@@ -2,8 +2,12 @@ define([
"../core",
"./var/rsingleTag",
"../manipulation" // buildFragment
], function( jQuery, rsingleTag ) {
// This is the only module that needs core/support
"./support",
// buildFragment
"../manipulation"
], function( jQuery, rsingleTag, support ) {
// data: string of html
// context (optional): If specified, the fragment will be created in this context,
@@ -17,7 +21,11 @@ jQuery.parseHTML = function( data, context, keepScripts ) {
keepScripts = context;
context = false;
}
context = context || document;
// document.implementation stops scripts or inline event handlers from
// being executed immediately
context = context || ( support.createHTMLDocument ?
document.implementation.createHTMLDocument( "" ) :
document );
var parsed = rsingleTag.exec( data ),
scripts = !keepScripts && [];

12
src/core/support.js Normal file
View File

@@ -0,0 +1,12 @@
define([
"../var/support"
], function( support ) {
support.createHTMLDocument = (function() {
var doc = document.implementation.createHTMLDocument( "" );
doc.body.innerHTML = "<form></form><form></form>";
return doc.body.childNodes.length === 2;
})();
return support;
});