| 1 | define( [
|
| 2 | "../core",
|
| 3 | "../var/document",
|
| 4 | "./var/rsingleTag",
|
| 5 | "../manipulation/buildFragment",
|
| 6 |
|
| 7 |
|
| 8 | "./support"
|
| 9 | ], function( jQuery, document, rsingleTag, buildFragment, support ) {
|
| 10 |
|
| 11 | "use strict";
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 | jQuery.parseHTML = function( data, context, keepScripts ) {
|
| 18 | if ( typeof data !== "string" ) {
|
| 19 | return [];
|
| 20 | }
|
| 21 | if ( typeof context === "boolean" ) {
|
| 22 | keepScripts = context;
|
| 23 | context = false;
|
| 24 | }
|
| 25 |
|
| 26 | var base, parsed, scripts;
|
| 27 |
|
| 28 | if ( !context ) {
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 | if ( support.createHTMLDocument ) {
|
| 33 | context = document.implementation.createHTMLDocument( "" );
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 | base = context.createElement( "base" );
|
| 39 | base.href = document.location.href;
|
| 40 | context.head.appendChild( base );
|
| 41 | } else {
|
| 42 | context = document;
|
| 43 | }
|
| 44 | }
|
| 45 |
|
| 46 | parsed = rsingleTag.exec( data );
|
| 47 | scripts = !keepScripts && [];
|
| 48 |
|
| 49 |
|
| 50 | if ( parsed ) {
|
| 51 | return [ context.createElement( parsed[ 1 ] ) ];
|
| 52 | }
|
| 53 |
|
| 54 | parsed = buildFragment( [ data ], context, scripts );
|
| 55 |
|
| 56 | if ( scripts && scripts.length ) {
|
| 57 | jQuery( scripts ).remove();
|
| 58 | }
|
| 59 |
|
| 60 | return jQuery.merge( [], parsed.childNodes );
|
| 61 | };
|
| 62 |
|
| 63 | return jQuery.parseHTML;
|
| 64 |
|
| 65 | } );
|