scratch – Diff between revs 58 and 125

Subversion Repositories:
Rev:
Show entire fileRegard whitespace
Rev 58 Rev 125
Line 1... Line 1...
1 // Initialize a jQuery object 1 // Initialize a jQuery object
2 define( [ 2 define([
3 "../core", 3 "../core",
4 "../var/document", -  
5 "./var/rsingleTag", 4 "./var/rsingleTag",
6 "../traversing/findFilter" 5 "../traversing/findFilter"
7 ], function( jQuery, document, rsingleTag ) { 6 ], function( jQuery, rsingleTag ) {
8   -  
9 "use strict"; -  
Line 10... Line 7...
10   7  
11 // A central reference to the root jQuery(document) 8 // A central reference to the root jQuery(document)
Line 12... Line 9...
12 var rootjQuery, 9 var rootjQuery,
13   10  
14 // A simple way to check for HTML strings 11 // A simple way to check for HTML strings
15 // Prioritize #id over <tag> to avoid XSS via location.hash (#9521) -  
16 // Strict HTML recognition (#11290: must start with <) 12 // Prioritize #id over <tag> to avoid XSS via location.hash (#9521)
Line 17... Line 13...
17 // Shortcut simple #id case for speed 13 // Strict HTML recognition (#11290: must start with <)
18 rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]+))$/, 14 rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/,
Line 19... Line 15...
19   15  
20 <[\w\W]+> init = jQuery.fn.init = function( selector, context, root ) { 16 <[\w\W]+> init = jQuery.fn.init = function( selector, context ) {
21 <[\w\W]+> var match, elem; 17 <[\w\W]+> var match, elem;
22   18  
Line 23... Line -...
23 <[\w\W]+> // HANDLE: $(""), $(null), $(undefined), $(false) -  
24 <[\w\W]+> if ( !selector ) { -  
25 <[\w\W]+> return this; -  
26 <[\w\W]+> } -  
27   19 <[\w\W]+> // HANDLE: $(""), $(null), $(undefined), $(false)
28 <[\w\W]+> // Method init() accepts an alternate rootjQuery 20 <[\w\W]+> if ( !selector ) {
29 <[\w\W]+> // so migrate can support jQuery.sub (gh-2101) -  
30 <[\w\W]+> root = root || rootjQuery; 21 <[\w\W]+> return this;
31   -  
32 <[\w\W]+> // Handle HTML strings -  
33 <[\w\W]+> if ( typeof selector === "string" ) { 22 <[\w\W]+> }
34 <[\w\W]+> if ( selector[ 0 ] === "<" && 23  
Line 35... Line 24...
35 <[\w\W]+> selector[ selector.length - 1 ] === ">" && 24 <[\w\W]+> // Handle HTML strings
36 <[\w\W]+> selector.length >= 3 ) { 25 <[\w\W]+> if ( typeof selector === "string" ) {
Line 58... Line 47...
58 <[\w\W]+> ) ); 47 <[\w\W]+> ) );
Line 59... Line 48...
59   48  
60 <[\w\W]+> // HANDLE: $(html, props) 49 <[\w\W]+> // HANDLE: $(html, props)
61 <[\w\W]+> if ( rsingleTag.test( match[ 1 ] ) && jQuery.isPlainObject( context ) ) { 50 <[\w\W]+> if ( rsingleTag.test( match[1] ) && jQuery.isPlainObject( context ) ) {
62 <[\w\W]+> for ( match in context ) { -  
63   51 <[\w\W]+> for ( match in context ) {
64 <[\w\W]+> // Properties of context are called as methods if possible 52 <[\w\W]+> // Properties of context are called as methods if possible
65 <[\w\W]+> if ( jQuery.isFunction( this[ match ] ) ) { 53 <[\w\W]+> if ( jQuery.isFunction( this[ match ] ) ) {
Line 66... Line 54...
66 <[\w\W]+> this[ match ]( context[ match ] ); 54 <[\w\W]+> this[ match ]( context[ match ] );
Line 76... Line 64...
76   64  
77 <[\w\W]+> // HANDLE: $(#id) 65 <[\w\W]+> // HANDLE: $(#id)
78 <[\w\W]+> } else { 66 <[\w\W]+> } else {
Line -... Line 67...
-   67 <[\w\W]+> elem = document.getElementById( match[2] );
-   68  
79 <[\w\W]+> elem = document.getElementById( match[ 2 ] ); 69 <[\w\W]+> // Support: Blackberry 4.6
80   -  
81 <[\w\W]+> if ( elem ) { 70 <[\w\W]+> // gEBID returns nodes no longer in the document (#6963)
82   -  
83 <[\w\W]+> // Inject the element directly into the jQuery object 71 <[\w\W]+> if ( elem && elem.parentNode ) {
-   72 <[\w\W]+> // Inject the element directly into the jQuery object
84 <[\w\W]+> this[ 0 ] = elem; 73 <[\w\W]+> this.length = 1;
-   74 <[\w\W]+> this[0] = elem;
-   75 <[\w\W]+> }
-   76  
85 <[\w\W]+> this.length = 1; 77 <[\w\W]+> this.context = document;
86 <[\w\W]+> } 78 <[\w\W]+> this.selector = selector;
Line 87... Line 79...
87 <[\w\W]+> return this; 79 <[\w\W]+> return this;
88 <[\w\W]+> } 80 <[\w\W]+> }
89   81  
Line 90... Line 82...
90 <[\w\W]+> // HANDLE: $(expr, $(...)) 82 <[\w\W]+> // HANDLE: $(expr, $(...))
91 <[\w\W]+> } else if ( !context || context.jquery ) { 83 <[\w\W]+> } else if ( !context || context.jquery ) {
92 <[\w\W]+> return ( context || root ).find( selector ); 84 <[\w\W]+> return ( context || rootjQuery ).find( selector );
93   85  
94 <[\w\W]+> // HANDLE: $(expr, context) 86 <[\w\W]+> // HANDLE: $(expr, context)
Line 95... Line 87...
95 <[\w\W]+> // (which is just equivalent to: $(context).find(expr) 87 <[\w\W]+> // (which is just equivalent to: $(context).find(expr)
96 <[\w\W]+> } else { 88 <[\w\W]+> } else {
97 <[\w\W]+> return this.constructor( context ).find( selector ); 89 <[\w\W]+> return this.constructor( context ).find( selector );
98 <[\w\W]+> } 90 <[\w\W]+> }
99   91  
Line 100... Line 92...
100 <[\w\W]+> // HANDLE: $(DOMElement) 92 <[\w\W]+> // HANDLE: $(DOMElement)
101 <[\w\W]+> } else if ( selector.nodeType ) { 93 <[\w\W]+> } else if ( selector.nodeType ) {
102 <[\w\W]+> this[ 0 ] = selector; 94 <[\w\W]+> this.context = this[0] = selector;
103 <[\w\W]+> this.length = 1; 95 <[\w\W]+> this.length = 1;
104 <[\w\W]+> return this; 96 <[\w\W]+> return this;
105   -  
106 <[\w\W]+> // HANDLE: $(function) 97  
107 <[\w\W]+> // Shortcut for document ready 98 <[\w\W]+> // HANDLE: $(function)
108 <[\w\W]+> } else if ( jQuery.isFunction( selector ) ) { 99 <[\w\W]+> // Shortcut for document ready
Line -... Line 100...
-   100 <[\w\W]+> } else if ( jQuery.isFunction( selector ) ) {
-   101 <[\w\W]+> return typeof rootjQuery.ready !== "undefined" ?
-   102 <[\w\W]+> rootjQuery.ready( selector ) :
-   103 <[\w\W]+> // Execute immediately if ready is not present
-   104 <[\w\W]+> selector( jQuery );
109 <[\w\W]+> return root.ready !== undefined ? 105 <[\w\W]+> }
110 <[\w\W]+> root.ready( selector ) : 106  
Line 111... Line 107...
111   107 <[\w\W]+> if ( selector.selector !== undefined ) {
112 <[\w\W]+> // Execute immediately if ready is not present 108 <[\w\W]+> this.selector = selector.selector;