Blame view

bower_components/jquery/src/core/parseHTML.js 1.25 KB
a1a3bc73   Luigi Serra   graphs updates
1
  define( [
74249687   Luigi Serra   Cross browser con...
2
  	"../core",
a1a3bc73   Luigi Serra   graphs updates
3
  	"../var/document",
74249687   Luigi Serra   Cross browser con...
4
  	"./var/rsingleTag",
a1a3bc73   Luigi Serra   graphs updates
5
  	"../manipulation/buildFragment",
74249687   Luigi Serra   Cross browser con...
6
  
a1a3bc73   Luigi Serra   graphs updates
7
8
9
10
11
12
13
  	// This is the only module that needs core/support
  	"./support"
  ], function( jQuery, document, rsingleTag, buildFragment, support ) {
  
  // Argument "data" should be string of html
  // context (optional): If specified, the fragment will be created in this context,
  // defaults to document
74249687   Luigi Serra   Cross browser con...
14
15
16
17
18
19
20
21
22
  // keepScripts (optional): If true, will include scripts passed in the html string
  jQuery.parseHTML = function( data, context, keepScripts ) {
  	if ( !data || typeof data !== "string" ) {
  		return null;
  	}
  	if ( typeof context === "boolean" ) {
  		keepScripts = context;
  		context = false;
  	}
a1a3bc73   Luigi Serra   graphs updates
23
24
25
26
27
28
  
  	// Stop scripts or inline event handlers from being executed immediately
  	// by using document.implementation
  	context = context || ( support.createHTMLDocument ?
  		document.implementation.createHTMLDocument( "" ) :
  		document );
74249687   Luigi Serra   Cross browser con...
29
30
31
32
33
34
  
  	var parsed = rsingleTag.exec( data ),
  		scripts = !keepScripts && [];
  
  	// Single tag
  	if ( parsed ) {
a1a3bc73   Luigi Serra   graphs updates
35
  		return [ context.createElement( parsed[ 1 ] ) ];
74249687   Luigi Serra   Cross browser con...
36
37
  	}
  
a1a3bc73   Luigi Serra   graphs updates
38
  	parsed = buildFragment( [ data ], context, scripts );
74249687   Luigi Serra   Cross browser con...
39
40
41
42
43
44
45
46
47
48
  
  	if ( scripts && scripts.length ) {
  		jQuery( scripts ).remove();
  	}
  
  	return jQuery.merge( [], parsed.childNodes );
  };
  
  return jQuery.parseHTML;
  
a1a3bc73   Luigi Serra   graphs updates
49
  } );