scratch – Blame information for rev 125

Subversion Repositories:
Rev:
Rev Author Line No. Line
58 office 1 // Initialize a jQuery object
125 office 2 define([
58 office 3 "../core",
4 "./var/rsingleTag",
5 "../traversing/findFilter"
125 office 6 ], function( jQuery, rsingleTag ) {
58 office 7  
8 // A central reference to the root jQuery(document)
9 var rootjQuery,
10  
11 // A simple way to check for HTML strings
12 // Prioritize #id over <tag> to avoid XSS via location.hash (#9521)
13 // Strict HTML recognition (#11290: must start with <)
125 office 14 rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/,
58 office 15  
125 office 16 <[\w\W]+> init = jQuery.fn.init = function( selector, context ) {
58 office 17 <[\w\W]+> var match, elem;
18  
19 <[\w\W]+> // HANDLE: $(""), $(null), $(undefined), $(false)
20 <[\w\W]+> if ( !selector ) {
21 <[\w\W]+> return this;
22 <[\w\W]+> }
23  
24 <[\w\W]+> // Handle HTML strings
25 <[\w\W]+> if ( typeof selector === "string" ) {
125 office 26 <[\w\W]+> if ( selector[0] === "<" && selector[ selector.length - 1 ] === ">" && selector.length >= 3 ) {
58 office 27 <[\w\W]+> // Assume that strings that start and end with <> are HTML and skip the regex check
28 <[\w\W]+> match = [ null, selector, null ];
29  
30 <[\w\W]+> } else {
31 <[\w\W]+> match = rquickExpr.exec( selector );
32 <[\w\W]+> }
33  
34 <[\w\W]+> // Match html or make sure no context is specified for #id
125 office 35 <[\w\W]+> if ( match && (match[1] || !context) ) {
58 office 36  
37 <[\w\W]+> // HANDLE: $(html) -> $(array)
125 office 38 <[\w\W]+> if ( match[1] ) {
39 <[\w\W]+> context = context instanceof jQuery ? context[0] : context;
58 office 40  
41 <[\w\W]+> // Option to run scripts is true for back-compat
42 <[\w\W]+> // Intentionally let the error be thrown if parseHTML is not present
43 <[\w\W]+> jQuery.merge( this, jQuery.parseHTML(
125 office 44 <[\w\W]+> match[1],
58 office 45 <[\w\W]+> context && context.nodeType ? context.ownerDocument || context : document,
46 <[\w\W]+> true
47 <[\w\W]+> ) );
48  
49 <[\w\W]+> // HANDLE: $(html, props)
125 office 50 <[\w\W]+> if ( rsingleTag.test( match[1] ) && jQuery.isPlainObject( context ) ) {
58 office 51 <[\w\W]+> for ( match in context ) {
52 <[\w\W]+> // Properties of context are called as methods if possible
53 <[\w\W]+> if ( jQuery.isFunction( this[ match ] ) ) {
54 <[\w\W]+> this[ match ]( context[ match ] );
55  
56 <[\w\W]+> // ...and otherwise set as attributes
57 <[\w\W]+> } else {
58 <[\w\W]+> this.attr( match, context[ match ] );
59 <[\w\W]+> }
60 <[\w\W]+> }
61 <[\w\W]+> }
62  
63 <[\w\W]+> return this;
64  
65 <[\w\W]+> // HANDLE: $(#id)
66 <[\w\W]+> } else {
125 office 67 <[\w\W]+> elem = document.getElementById( match[2] );
58 office 68  
125 office 69 <[\w\W]+> // Support: Blackberry 4.6
70 <[\w\W]+> // gEBID returns nodes no longer in the document (#6963)
71 <[\w\W]+> if ( elem && elem.parentNode ) {
58 office 72 <[\w\W]+> // Inject the element directly into the jQuery object
73 <[\w\W]+> this.length = 1;
125 office 74 <[\w\W]+> this[0] = elem;
58 office 75 <[\w\W]+> }
125 office 76  
77 <[\w\W]+> this.context = document;
78 <[\w\W]+> this.selector = selector;
58 office 79 <[\w\W]+> return this;
80 <[\w\W]+> }
81  
82 <[\w\W]+> // HANDLE: $(expr, $(...))
83 <[\w\W]+> } else if ( !context || context.jquery ) {
125 office 84 <[\w\W]+> return ( context || rootjQuery ).find( selector );
58 office 85  
86 <[\w\W]+> // HANDLE: $(expr, context)
87 <[\w\W]+> // (which is just equivalent to: $(context).find(expr)
88 <[\w\W]+> } else {
89 <[\w\W]+> return this.constructor( context ).find( selector );
90 <[\w\W]+> }
91  
92 <[\w\W]+> // HANDLE: $(DOMElement)
93 <[\w\W]+> } else if ( selector.nodeType ) {
125 office 94 <[\w\W]+> this.context = this[0] = selector;
58 office 95 <[\w\W]+> this.length = 1;
96 <[\w\W]+> return this;
97  
98 <[\w\W]+> // HANDLE: $(function)
99 <[\w\W]+> // Shortcut for document ready
100 <[\w\W]+> } else if ( jQuery.isFunction( selector ) ) {
125 office 101 <[\w\W]+> return typeof rootjQuery.ready !== "undefined" ?
102 <[\w\W]+> rootjQuery.ready( selector ) :
58 office 103 <[\w\W]+> // Execute immediately if ready is not present
104 <[\w\W]+> selector( jQuery );
105 <[\w\W]+> }
106  
125 office 107 <[\w\W]+> if ( selector.selector !== undefined ) {
108 <[\w\W]+> this.selector = selector.selector;
109 <[\w\W]+> this.context = selector.context;
110 <[\w\W]+> }
111  
58 office 112 <[\w\W]+> return jQuery.makeArray( selector, this );
113 <[\w\W]+> };
114  
115 <[\w\W]+>// Give the init function the jQuery prototype for later instantiation
116 <[\w\W]+>init.prototype = jQuery.fn;
117  
118 <[\w\W]+>// Initialize central reference
119 <[\w\W]+>rootjQuery = jQuery( document );
120  
121 <[\w\W]+>return init;
122  
125 office 123 <[\w\W]+>});