aboutsummaryrefslogtreecommitdiffstats
path: root/src/core
diff options
context:
space:
mode:
authorTimmy Willison <timmywillisn@gmail.com>2014-12-10 09:48:55 -0500
committerTimmy Willison <timmywillisn@gmail.com>2014-12-10 09:51:30 -0500
commitcfe468f29c4cbe1a457d0feb17dec90dcfd7c280 (patch)
tree95ee702e8f3be147f0bb7f5f7f34226cac435927 /src/core
parent8653068dd6b8a515f5c1d8a0fda4479e9534103e (diff)
downloadjquery-cfe468f29c4cbe1a457d0feb17dec90dcfd7c280.tar.gz
jquery-cfe468f29c4cbe1a457d0feb17dec90dcfd7c280.zip
Core: re-introduce createHTMLDocument in parseHTML; Safari 8 left out
Close gh-1505
Diffstat (limited to 'src/core')
-rw-r--r--src/core/parseHTML.js14
-rw-r--r--src/core/support.js12
2 files changed, 23 insertions, 3 deletions
diff --git a/src/core/parseHTML.js b/src/core/parseHTML.js
index e0348971d..2b638e633 100644
--- a/src/core/parseHTML.js
+++ b/src/core/parseHTML.js
@@ -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 && [];
diff --git a/src/core/support.js b/src/core/support.js
new file mode 100644
index 000000000..ebed460ae
--- /dev/null
+++ b/src/core/support.js
@@ -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;
+});