| @@ 2866-2979 (lines=114) @@ | ||
| 2863 | // Strict HTML recognition (#11290: must start with <) |
|
| 2864 | rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/, |
|
| 2865 | ||
| 2866 | init = jQuery.fn.init = function( selector, context, root ) { |
|
| 2867 | var match, elem; |
|
| 2868 | ||
| 2869 | // HANDLE: $(""), $(null), $(undefined), $(false) |
|
| 2870 | if ( !selector ) { |
|
| 2871 | return this; |
|
| 2872 | } |
|
| 2873 | ||
| 2874 | // init accepts an alternate rootjQuery |
|
| 2875 | // so migrate can support jQuery.sub (gh-2101) |
|
| 2876 | root = root || rootjQuery; |
|
| 2877 | ||
| 2878 | // Handle HTML strings |
|
| 2879 | if ( typeof selector === "string" ) { |
|
| 2880 | if ( selector.charAt( 0 ) === "<" && |
|
| 2881 | selector.charAt( selector.length - 1 ) === ">" && |
|
| 2882 | selector.length >= 3 ) { |
|
| 2883 | ||
| 2884 | // Assume that strings that start and end with <> are HTML and skip the regex check |
|
| 2885 | match = [ null, selector, null ]; |
|
| 2886 | ||
| 2887 | } else { |
|
| 2888 | match = rquickExpr.exec( selector ); |
|
| 2889 | } |
|
| 2890 | ||
| 2891 | // Match html or make sure no context is specified for #id |
|
| 2892 | if ( match && ( match[ 1 ] || !context ) ) { |
|
| 2893 | ||
| 2894 | // HANDLE: $(html) -> $(array) |
|
| 2895 | if ( match[ 1 ] ) { |
|
| 2896 | context = context instanceof jQuery ? context[ 0 ] : context; |
|
| 2897 | ||
| 2898 | // scripts is true for back-compat |
|
| 2899 | // Intentionally let the error be thrown if parseHTML is not present |
|
| 2900 | jQuery.merge( this, jQuery.parseHTML( |
|
| 2901 | match[ 1 ], |
|
| 2902 | context && context.nodeType ? context.ownerDocument || context : document, |
|
| 2903 | true |
|
| 2904 | ) ); |
|
| 2905 | ||
| 2906 | // HANDLE: $(html, props) |
|
| 2907 | if ( rsingleTag.test( match[ 1 ] ) && jQuery.isPlainObject( context ) ) { |
|
| 2908 | for ( match in context ) { |
|
| 2909 | ||
| 2910 | // Properties of context are called as methods if possible |
|
| 2911 | if ( jQuery.isFunction( this[ match ] ) ) { |
|
| 2912 | this[ match ]( context[ match ] ); |
|
| 2913 | ||
| 2914 | // ...and otherwise set as attributes |
|
| 2915 | } else { |
|
| 2916 | this.attr( match, context[ match ] ); |
|
| 2917 | } |
|
| 2918 | } |
|
| 2919 | } |
|
| 2920 | ||
| 2921 | return this; |
|
| 2922 | ||
| 2923 | // HANDLE: $(#id) |
|
| 2924 | } else { |
|
| 2925 | elem = document.getElementById( match[ 2 ] ); |
|
| 2926 | ||
| 2927 | // Check parentNode to catch when Blackberry 4.6 returns |
|
| 2928 | // nodes that are no longer in the document #6963 |
|
| 2929 | if ( elem && elem.parentNode ) { |
|
| 2930 | ||
| 2931 | // Handle the case where IE and Opera return items |
|
| 2932 | // by name instead of ID |
|
| 2933 | if ( elem.id !== match[ 2 ] ) { |
|
| 2934 | return rootjQuery.find( selector ); |
|
| 2935 | } |
|
| 2936 | ||
| 2937 | // Otherwise, we inject the element directly into the jQuery object |
|
| 2938 | this.length = 1; |
|
| 2939 | this[ 0 ] = elem; |
|
| 2940 | } |
|
| 2941 | ||
| 2942 | this.context = document; |
|
| 2943 | this.selector = selector; |
|
| 2944 | return this; |
|
| 2945 | } |
|
| 2946 | ||
| 2947 | // HANDLE: $(expr, $(...)) |
|
| 2948 | } else if ( !context || context.jquery ) { |
|
| 2949 | return ( context || root ).find( selector ); |
|
| 2950 | ||
| 2951 | // HANDLE: $(expr, context) |
|
| 2952 | // (which is just equivalent to: $(context).find(expr) |
|
| 2953 | } else { |
|
| 2954 | return this.constructor( context ).find( selector ); |
|
| 2955 | } |
|
| 2956 | ||
| 2957 | // HANDLE: $(DOMElement) |
|
| 2958 | } else if ( selector.nodeType ) { |
|
| 2959 | this.context = this[ 0 ] = selector; |
|
| 2960 | this.length = 1; |
|
| 2961 | return this; |
|
| 2962 | ||
| 2963 | // HANDLE: $(function) |
|
| 2964 | // Shortcut for document ready |
|
| 2965 | } else if ( jQuery.isFunction( selector ) ) { |
|
| 2966 | return typeof root.ready !== "undefined" ? |
|
| 2967 | root.ready( selector ) : |
|
| 2968 | ||
| 2969 | // Execute immediately if ready is not present |
|
| 2970 | selector( jQuery ); |
|
| 2971 | } |
|
| 2972 | ||
| 2973 | if ( selector.selector !== undefined ) { |
|
| 2974 | this.selector = selector.selector; |
|
| 2975 | this.context = selector.context; |
|
| 2976 | } |
|
| 2977 | ||
| 2978 | return jQuery.makeArray( selector, this ); |
|
| 2979 | }; |
|
| 2980 | ||
| 2981 | // Give the init function the jQuery prototype for later instantiation |
|
| 2982 | init.prototype = jQuery.fn; |
|
| @@ 2827-2934 (lines=108) @@ | ||
| 2824 | // Strict HTML recognition (#11290: must start with <) |
|
| 2825 | rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/, |
|
| 2826 | ||
| 2827 | init = jQuery.fn.init = function( selector, context, root ) { |
|
| 2828 | var match, elem; |
|
| 2829 | ||
| 2830 | // HANDLE: $(""), $(null), $(undefined), $(false) |
|
| 2831 | if ( !selector ) { |
|
| 2832 | return this; |
|
| 2833 | } |
|
| 2834 | ||
| 2835 | // Method init() accepts an alternate rootjQuery |
|
| 2836 | // so migrate can support jQuery.sub (gh-2101) |
|
| 2837 | root = root || rootjQuery; |
|
| 2838 | ||
| 2839 | // Handle HTML strings |
|
| 2840 | if ( typeof selector === "string" ) { |
|
| 2841 | if ( selector[ 0 ] === "<" && |
|
| 2842 | selector[ selector.length - 1 ] === ">" && |
|
| 2843 | selector.length >= 3 ) { |
|
| 2844 | ||
| 2845 | // Assume that strings that start and end with <> are HTML and skip the regex check |
|
| 2846 | match = [ null, selector, null ]; |
|
| 2847 | ||
| 2848 | } else { |
|
| 2849 | match = rquickExpr.exec( selector ); |
|
| 2850 | } |
|
| 2851 | ||
| 2852 | // Match html or make sure no context is specified for #id |
|
| 2853 | if ( match && ( match[ 1 ] || !context ) ) { |
|
| 2854 | ||
| 2855 | // HANDLE: $(html) -> $(array) |
|
| 2856 | if ( match[ 1 ] ) { |
|
| 2857 | context = context instanceof jQuery ? context[ 0 ] : context; |
|
| 2858 | ||
| 2859 | // Option to run scripts is true for back-compat |
|
| 2860 | // Intentionally let the error be thrown if parseHTML is not present |
|
| 2861 | jQuery.merge( this, jQuery.parseHTML( |
|
| 2862 | match[ 1 ], |
|
| 2863 | context && context.nodeType ? context.ownerDocument || context : document, |
|
| 2864 | true |
|
| 2865 | ) ); |
|
| 2866 | ||
| 2867 | // HANDLE: $(html, props) |
|
| 2868 | if ( rsingleTag.test( match[ 1 ] ) && jQuery.isPlainObject( context ) ) { |
|
| 2869 | for ( match in context ) { |
|
| 2870 | ||
| 2871 | // Properties of context are called as methods if possible |
|
| 2872 | if ( jQuery.isFunction( this[ match ] ) ) { |
|
| 2873 | this[ match ]( context[ match ] ); |
|
| 2874 | ||
| 2875 | // ...and otherwise set as attributes |
|
| 2876 | } else { |
|
| 2877 | this.attr( match, context[ match ] ); |
|
| 2878 | } |
|
| 2879 | } |
|
| 2880 | } |
|
| 2881 | ||
| 2882 | return this; |
|
| 2883 | ||
| 2884 | // HANDLE: $(#id) |
|
| 2885 | } else { |
|
| 2886 | elem = document.getElementById( match[ 2 ] ); |
|
| 2887 | ||
| 2888 | // Support: Blackberry 4.6 |
|
| 2889 | // gEBID returns nodes no longer in the document (#6963) |
|
| 2890 | if ( elem && elem.parentNode ) { |
|
| 2891 | ||
| 2892 | // Inject the element directly into the jQuery object |
|
| 2893 | this.length = 1; |
|
| 2894 | this[ 0 ] = elem; |
|
| 2895 | } |
|
| 2896 | ||
| 2897 | this.context = document; |
|
| 2898 | this.selector = selector; |
|
| 2899 | return this; |
|
| 2900 | } |
|
| 2901 | ||
| 2902 | // HANDLE: $(expr, $(...)) |
|
| 2903 | } else if ( !context || context.jquery ) { |
|
| 2904 | return ( context || root ).find( selector ); |
|
| 2905 | ||
| 2906 | // HANDLE: $(expr, context) |
|
| 2907 | // (which is just equivalent to: $(context).find(expr) |
|
| 2908 | } else { |
|
| 2909 | return this.constructor( context ).find( selector ); |
|
| 2910 | } |
|
| 2911 | ||
| 2912 | // HANDLE: $(DOMElement) |
|
| 2913 | } else if ( selector.nodeType ) { |
|
| 2914 | this.context = this[ 0 ] = selector; |
|
| 2915 | this.length = 1; |
|
| 2916 | return this; |
|
| 2917 | ||
| 2918 | // HANDLE: $(function) |
|
| 2919 | // Shortcut for document ready |
|
| 2920 | } else if ( jQuery.isFunction( selector ) ) { |
|
| 2921 | return root.ready !== undefined ? |
|
| 2922 | root.ready( selector ) : |
|
| 2923 | ||
| 2924 | // Execute immediately if ready is not present |
|
| 2925 | selector( jQuery ); |
|
| 2926 | } |
|
| 2927 | ||
| 2928 | if ( selector.selector !== undefined ) { |
|
| 2929 | this.selector = selector.selector; |
|
| 2930 | this.context = selector.context; |
|
| 2931 | } |
|
| 2932 | ||
| 2933 | return jQuery.makeArray( selector, this ); |
|
| 2934 | }; |
|
| 2935 | ||
| 2936 | // Give the init function the jQuery prototype for later instantiation |
|
| 2937 | init.prototype = jQuery.fn; |
|
| @@ 2708-2805 (lines=98) @@ | ||
| 2705 | // Strict HTML recognition (#11290: must start with <) |
|
| 2706 | rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/, |
|
| 2707 | ||
| 2708 | init = jQuery.fn.init = function( selector, context ) { |
|
| 2709 | var match, elem; |
|
| 2710 | ||
| 2711 | // HANDLE: $(""), $(null), $(undefined), $(false) |
|
| 2712 | if ( !selector ) { |
|
| 2713 | return this; |
|
| 2714 | } |
|
| 2715 | ||
| 2716 | // Handle HTML strings |
|
| 2717 | if ( typeof selector === "string" ) { |
|
| 2718 | if ( selector[0] === "<" && selector[ selector.length - 1 ] === ">" && selector.length >= 3 ) { |
|
| 2719 | // Assume that strings that start and end with <> are HTML and skip the regex check |
|
| 2720 | match = [ null, selector, null ]; |
|
| 2721 | ||
| 2722 | } else { |
|
| 2723 | match = rquickExpr.exec( selector ); |
|
| 2724 | } |
|
| 2725 | ||
| 2726 | // Match html or make sure no context is specified for #id |
|
| 2727 | if ( match && (match[1] || !context) ) { |
|
| 2728 | ||
| 2729 | // HANDLE: $(html) -> $(array) |
|
| 2730 | if ( match[1] ) { |
|
| 2731 | context = context instanceof jQuery ? context[0] : context; |
|
| 2732 | ||
| 2733 | // scripts is true for back-compat |
|
| 2734 | // Intentionally let the error be thrown if parseHTML is not present |
|
| 2735 | jQuery.merge( this, jQuery.parseHTML( |
|
| 2736 | match[1], |
|
| 2737 | context && context.nodeType ? context.ownerDocument || context : document, |
|
| 2738 | true |
|
| 2739 | ) ); |
|
| 2740 | ||
| 2741 | // HANDLE: $(html, props) |
|
| 2742 | if ( rsingleTag.test( match[1] ) && jQuery.isPlainObject( context ) ) { |
|
| 2743 | for ( match in context ) { |
|
| 2744 | // Properties of context are called as methods if possible |
|
| 2745 | if ( jQuery.isFunction( this[ match ] ) ) { |
|
| 2746 | this[ match ]( context[ match ] ); |
|
| 2747 | ||
| 2748 | // ...and otherwise set as attributes |
|
| 2749 | } else { |
|
| 2750 | this.attr( match, context[ match ] ); |
|
| 2751 | } |
|
| 2752 | } |
|
| 2753 | } |
|
| 2754 | ||
| 2755 | return this; |
|
| 2756 | ||
| 2757 | // HANDLE: $(#id) |
|
| 2758 | } else { |
|
| 2759 | elem = document.getElementById( match[2] ); |
|
| 2760 | ||
| 2761 | // Check parentNode to catch when Blackberry 4.6 returns |
|
| 2762 | // nodes that are no longer in the document #6963 |
|
| 2763 | if ( elem && elem.parentNode ) { |
|
| 2764 | // Inject the element directly into the jQuery object |
|
| 2765 | this.length = 1; |
|
| 2766 | this[0] = elem; |
|
| 2767 | } |
|
| 2768 | ||
| 2769 | this.context = document; |
|
| 2770 | this.selector = selector; |
|
| 2771 | return this; |
|
| 2772 | } |
|
| 2773 | ||
| 2774 | // HANDLE: $(expr, $(...)) |
|
| 2775 | } else if ( !context || context.jquery ) { |
|
| 2776 | return ( context || rootjQuery ).find( selector ); |
|
| 2777 | ||
| 2778 | // HANDLE: $(expr, context) |
|
| 2779 | // (which is just equivalent to: $(context).find(expr) |
|
| 2780 | } else { |
|
| 2781 | return this.constructor( context ).find( selector ); |
|
| 2782 | } |
|
| 2783 | ||
| 2784 | // HANDLE: $(DOMElement) |
|
| 2785 | } else if ( selector.nodeType ) { |
|
| 2786 | this.context = this[0] = selector; |
|
| 2787 | this.length = 1; |
|
| 2788 | return this; |
|
| 2789 | ||
| 2790 | // HANDLE: $(function) |
|
| 2791 | // Shortcut for document ready |
|
| 2792 | } else if ( jQuery.isFunction( selector ) ) { |
|
| 2793 | return typeof rootjQuery.ready !== "undefined" ? |
|
| 2794 | rootjQuery.ready( selector ) : |
|
| 2795 | // Execute immediately if ready is not present |
|
| 2796 | selector( jQuery ); |
|
| 2797 | } |
|
| 2798 | ||
| 2799 | if ( selector.selector !== undefined ) { |
|
| 2800 | this.selector = selector.selector; |
|
| 2801 | this.context = selector.context; |
|
| 2802 | } |
|
| 2803 | ||
| 2804 | return jQuery.makeArray( selector, this ); |
|
| 2805 | }; |
|
| 2806 | ||
| 2807 | // Give the init function the jQuery prototype for later instantiation |
|
| 2808 | init.prototype = jQuery.fn; |
|