diff options
author | Frederic Hemberger <mail@frederic-hemberger.de> | 2014-12-09 15:13:46 -0500 |
---|---|---|
committer | Timmy Willison <timmywillisn@gmail.com> | 2014-12-09 15:19:01 -0500 |
commit | 58c24608210c9a9a264a38746628ebc26823f59b (patch) | |
tree | f62d826814db8afba51396f02b46d16b32a48fed /src | |
parent | 43faf6d1f922ba44a84c93f4ff2461d208b2bf48 (diff) | |
download | jquery-58c24608210c9a9a264a38746628ebc26823f59b.tar.gz jquery-58c24608210c9a9a264a38746628ebc26823f59b.zip |
Core: use document.implemenation.createHTMLDocument in jQuery.parseHTML
Close gh-1505
Diffstat (limited to 'src')
-rw-r--r-- | src/core.js | 2 | ||||
-rw-r--r-- | src/core/parseHTML.js | 8 | ||||
-rw-r--r-- | src/core/support.js | 6 |
3 files changed, 13 insertions, 3 deletions
diff --git a/src/core.js b/src/core.js index fa8436a01..dab633f9c 100644 --- a/src/core.js +++ b/src/core.js @@ -7,7 +7,7 @@ define([ "./var/class2type", "./var/toString", "./var/hasOwn", - "./var/support" + "./core/support" ], function( arr, slice, concat, push, indexOf, class2type, toString, hasOwn, support ) { var diff --git a/src/core/parseHTML.js b/src/core/parseHTML.js index 808d60e3d..54016a4c1 100644 --- a/src/core/parseHTML.js +++ b/src/core/parseHTML.js @@ -2,7 +2,7 @@ define([ "../core", "./var/rsingleTag", "../manipulation" // buildFragment -], function( jQuery, rsingleTag ) { +], function( jQuery, rsingleTag, support ) { // data: string of html // context (optional): If specified, the fragment will be created in this context, @@ -16,7 +16,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..fe3d6c218 --- /dev/null +++ b/src/core/support.js @@ -0,0 +1,6 @@ +define([ + "../var/support" +], function( jQuery, support ) { + // window.document is used here as it's before the sandboxed document + support.createHTMLDocument = !!window.document.implementation.createHTMLDocument; +}); |