mirror of
https://github.com/jquery/jquery.git
synced 2026-04-20 03:01:22 -04:00
Core: introduce createHTMLDocument in parseHTML; Safari 8/IE8 left out
Close gh-1506
This commit is contained in:
@@ -1,8 +1,13 @@
|
||||
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,
|
||||
@@ -16,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 && [];
|
||||
|
||||
15
src/core/support.js
Normal file
15
src/core/support.js
Normal file
@@ -0,0 +1,15 @@
|
||||
define([
|
||||
"../var/support"
|
||||
], function( support ) {
|
||||
|
||||
support.createHTMLDocument = (function() {
|
||||
if ( !document.implementation.createHTMLDocument ) {
|
||||
return false;
|
||||
}
|
||||
var doc = document.implementation.createHTMLDocument( "" );
|
||||
doc.body.innerHTML = "<form></form><form></form>";
|
||||
return doc.body.childNodes.length === 2;
|
||||
})();
|
||||
|
||||
return support;
|
||||
});
|
||||
Reference in New Issue
Block a user