diff options
Diffstat (limited to 'js/vendor/jquery/src/core')
-rw-r--r-- | js/vendor/jquery/src/core/access.js | 17 | ||||
-rw-r--r-- | js/vendor/jquery/src/core/init.js | 43 | ||||
-rw-r--r-- | js/vendor/jquery/src/core/parseHTML.js | 28 | ||||
-rw-r--r-- | js/vendor/jquery/src/core/ready.js | 34 | ||||
-rw-r--r-- | js/vendor/jquery/src/core/support.js | 18 | ||||
-rw-r--r-- | js/vendor/jquery/src/core/var/rsingleTag.js | 7 |
6 files changed, 99 insertions, 48 deletions
diff --git a/js/vendor/jquery/src/core/access.js b/js/vendor/jquery/src/core/access.js index b6110c8f3..19f79efa4 100644 --- a/js/vendor/jquery/src/core/access.js +++ b/js/vendor/jquery/src/core/access.js @@ -1,10 +1,10 @@ -define([ +define( [ "../core" ], function( jQuery ) { // Multifunctional method to get and set values of a collection // The value/s can optionally be executed if it's a function -var access = jQuery.access = function( elems, fn, key, value, chainable, emptyGet, raw ) { +var access = function( elems, fn, key, value, chainable, emptyGet, raw ) { var i = 0, len = elems.length, bulk = key == null; @@ -13,7 +13,7 @@ var access = jQuery.access = function( elems, fn, key, value, chainable, emptyGe if ( jQuery.type( key ) === "object" ) { chainable = true; for ( i in key ) { - jQuery.access( elems, fn, i, key[i], true, emptyGet, raw ); + access( elems, fn, i, key[ i ], true, emptyGet, raw ); } // Sets one value @@ -25,6 +25,7 @@ var access = jQuery.access = function( elems, fn, key, value, chainable, emptyGe } if ( bulk ) { + // Bulk operations run against the entire set if ( raw ) { fn.call( elems, value ); @@ -41,7 +42,11 @@ var access = jQuery.access = function( elems, fn, key, value, chainable, emptyGe if ( fn ) { for ( ; i < len; i++ ) { - fn( elems[i], key, raw ? value : value.call( elems[i], i, fn( elems[i], key ) ) ); + fn( + elems[ i ], key, raw ? + value : + value.call( elems[ i ], i, fn( elems[ i ], key ) ) + ); } } } @@ -52,9 +57,9 @@ var access = jQuery.access = function( elems, fn, key, value, chainable, emptyGe // Gets bulk ? fn.call( elems ) : - len ? fn( elems[0], key ) : emptyGet; + len ? fn( elems[ 0 ], key ) : emptyGet; }; return access; -}); +} ); diff --git a/js/vendor/jquery/src/core/init.js b/js/vendor/jquery/src/core/init.js index 7e83a0496..c2b6c94d7 100644 --- a/js/vendor/jquery/src/core/init.js +++ b/js/vendor/jquery/src/core/init.js @@ -1,9 +1,10 @@ // Initialize a jQuery object -define([ +define( [ "../core", + "../var/document", "./var/rsingleTag", "../traversing/findFilter" -], function( jQuery, rsingleTag ) { +], function( jQuery, document, rsingleTag ) { // A central reference to the root jQuery(document) var rootjQuery, @@ -13,7 +14,7 @@ var rootjQuery, // Strict HTML recognition (#11290: must start with <) rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/, - init = jQuery.fn.init = function( selector, context ) { + init = jQuery.fn.init = function( selector, context, root ) { var match, elem; // HANDLE: $(""), $(null), $(undefined), $(false) @@ -21,9 +22,16 @@ var rootjQuery, return this; } + // Method init() accepts an alternate rootjQuery + // so migrate can support jQuery.sub (gh-2101) + root = root || rootjQuery; + // Handle HTML strings if ( typeof selector === "string" ) { - if ( selector[0] === "<" && selector[ selector.length - 1 ] === ">" && selector.length >= 3 ) { + if ( selector[ 0 ] === "<" && + selector[ selector.length - 1 ] === ">" && + selector.length >= 3 ) { + // Assume that strings that start and end with <> are HTML and skip the regex check match = [ null, selector, null ]; @@ -32,23 +40,24 @@ var rootjQuery, } // Match html or make sure no context is specified for #id - if ( match && (match[1] || !context) ) { + if ( match && ( match[ 1 ] || !context ) ) { // HANDLE: $(html) -> $(array) - if ( match[1] ) { - context = context instanceof jQuery ? context[0] : context; + if ( match[ 1 ] ) { + context = context instanceof jQuery ? context[ 0 ] : context; // Option to run scripts is true for back-compat // Intentionally let the error be thrown if parseHTML is not present jQuery.merge( this, jQuery.parseHTML( - match[1], + match[ 1 ], context && context.nodeType ? context.ownerDocument || context : document, true ) ); // HANDLE: $(html, props) - if ( rsingleTag.test( match[1] ) && jQuery.isPlainObject( context ) ) { + if ( rsingleTag.test( match[ 1 ] ) && jQuery.isPlainObject( context ) ) { for ( match in context ) { + // Properties of context are called as methods if possible if ( jQuery.isFunction( this[ match ] ) ) { this[ match ]( context[ match ] ); @@ -64,14 +73,15 @@ var rootjQuery, // HANDLE: $(#id) } else { - elem = document.getElementById( match[2] ); + elem = document.getElementById( match[ 2 ] ); // Support: Blackberry 4.6 // gEBID returns nodes no longer in the document (#6963) if ( elem && elem.parentNode ) { + // Inject the element directly into the jQuery object this.length = 1; - this[0] = elem; + this[ 0 ] = elem; } this.context = document; @@ -81,7 +91,7 @@ var rootjQuery, // HANDLE: $(expr, $(...)) } else if ( !context || context.jquery ) { - return ( context || rootjQuery ).find( selector ); + return ( context || root ).find( selector ); // HANDLE: $(expr, context) // (which is just equivalent to: $(context).find(expr) @@ -91,15 +101,16 @@ var rootjQuery, // HANDLE: $(DOMElement) } else if ( selector.nodeType ) { - this.context = this[0] = selector; + this.context = this[ 0 ] = selector; this.length = 1; return this; // HANDLE: $(function) // Shortcut for document ready } else if ( jQuery.isFunction( selector ) ) { - return typeof rootjQuery.ready !== "undefined" ? - rootjQuery.ready( selector ) : + return root.ready !== undefined ? + root.ready( selector ) : + // Execute immediately if ready is not present selector( jQuery ); } @@ -120,4 +131,4 @@ rootjQuery = jQuery( document ); return init; -}); +} ); diff --git a/js/vendor/jquery/src/core/parseHTML.js b/js/vendor/jquery/src/core/parseHTML.js index 64cf2a18a..87c2147d1 100644 --- a/js/vendor/jquery/src/core/parseHTML.js +++ b/js/vendor/jquery/src/core/parseHTML.js @@ -1,11 +1,16 @@ -define([ +define( [ "../core", + "../var/document", "./var/rsingleTag", - "../manipulation" // buildFragment -], function( jQuery, rsingleTag ) { + "../manipulation/buildFragment", -// data: string of html -// context (optional): If specified, the fragment will be created in this context, defaults to document + // 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 // keepScripts (optional): If true, will include scripts passed in the html string jQuery.parseHTML = function( data, context, keepScripts ) { if ( !data || typeof data !== "string" ) { @@ -15,17 +20,22 @@ jQuery.parseHTML = function( data, context, keepScripts ) { keepScripts = context; context = false; } - context = context || document; + + // Stop scripts or inline event handlers from being executed immediately + // by using document.implementation + context = context || ( support.createHTMLDocument ? + document.implementation.createHTMLDocument( "" ) : + document ); var parsed = rsingleTag.exec( data ), scripts = !keepScripts && []; // Single tag if ( parsed ) { - return [ context.createElement( parsed[1] ) ]; + return [ context.createElement( parsed[ 1 ] ) ]; } - parsed = jQuery.buildFragment( [ data ], context, scripts ); + parsed = buildFragment( [ data ], context, scripts ); if ( scripts && scripts.length ) { jQuery( scripts ).remove(); @@ -36,4 +46,4 @@ jQuery.parseHTML = function( data, context, keepScripts ) { return jQuery.parseHTML; -}); +} ); diff --git a/js/vendor/jquery/src/core/ready.js b/js/vendor/jquery/src/core/ready.js index db1a6e60a..7d93e6768 100644 --- a/js/vendor/jquery/src/core/ready.js +++ b/js/vendor/jquery/src/core/ready.js @@ -1,20 +1,23 @@ -define([ +define( [ "../core", + "../var/document", "../core/init", "../deferred" -], function( jQuery ) { +], function( jQuery, document ) { // The deferred used on DOM ready var readyList; jQuery.fn.ready = function( fn ) { + // Add the callback jQuery.ready.promise().done( fn ); return this; }; -jQuery.extend({ +jQuery.extend( { + // Is the DOM ready to be used? Set to true once it occurs. isReady: false, @@ -56,14 +59,14 @@ jQuery.extend({ jQuery( document ).off( "ready" ); } } -}); +} ); /** * The ready event handler and self cleanup method */ function completed() { - document.removeEventListener( "DOMContentLoaded", completed, false ); - window.removeEventListener( "load", completed, false ); + document.removeEventListener( "DOMContentLoaded", completed ); + window.removeEventListener( "load", completed ); jQuery.ready(); } @@ -72,20 +75,23 @@ jQuery.ready.promise = function( obj ) { readyList = jQuery.Deferred(); - // Catch cases where $(document).ready() is called after the browser event has already occurred. - // We once tried to use readyState "interactive" here, but it caused issues like the one - // discovered by ChrisS here: http://bugs.jquery.com/ticket/12282#comment:15 - if ( document.readyState === "complete" ) { + // Catch cases where $(document).ready() is called + // after the browser event has already occurred. + // Support: IE9-10 only + // Older IE sometimes signals "interactive" too soon + if ( document.readyState === "complete" || + ( document.readyState !== "loading" && !document.documentElement.doScroll ) ) { + // Handle it asynchronously to allow scripts the opportunity to delay ready - setTimeout( jQuery.ready ); + window.setTimeout( jQuery.ready ); } else { // Use the handy event callback - document.addEventListener( "DOMContentLoaded", completed, false ); + document.addEventListener( "DOMContentLoaded", completed ); // A fallback to window.onload, that will always work - window.addEventListener( "load", completed, false ); + window.addEventListener( "load", completed ); } } return readyList.promise( obj ); @@ -94,4 +100,4 @@ jQuery.ready.promise = function( obj ) { // Kick off the DOM ready check even if the user does not jQuery.ready.promise(); -}); +} ); diff --git a/js/vendor/jquery/src/core/support.js b/js/vendor/jquery/src/core/support.js new file mode 100644 index 000000000..0609a700b --- /dev/null +++ b/js/vendor/jquery/src/core/support.js @@ -0,0 +1,18 @@ +define( [ + "../var/document", + "../var/support" +], function( document, support ) { + +// Support: Safari 8+ +// In Safari 8 documents created via document.implementation.createHTMLDocument +// collapse sibling forms: the second one becomes a child of the first one. +// Because of that, this security measure has to be disabled in Safari 8. +// https://bugs.webkit.org/show_bug.cgi?id=137337 +support.createHTMLDocument = ( function() { + var body = document.implementation.createHTMLDocument( "" ).body; + body.innerHTML = "<form></form><form></form>"; + return body.childNodes.length === 2; +} )(); + +return support; +} ); diff --git a/js/vendor/jquery/src/core/var/rsingleTag.js b/js/vendor/jquery/src/core/var/rsingleTag.js index 7e7090b77..1a55ee39d 100644 --- a/js/vendor/jquery/src/core/var/rsingleTag.js +++ b/js/vendor/jquery/src/core/var/rsingleTag.js @@ -1,4 +1,5 @@ -define(function() { +define( function() { + // Match a standalone tag - return (/^<(\w+)\s*\/?>(?:<\/\1>|)$/); -}); + return ( /^<([\w-]+)\s*\/?>(?:<\/\1>|)$/ ); +} ); |