### Start Test Server Source: https://github.com/jquery/jquery-migrate/blob/main/CONTRIBUTING.md Launch the local test server to run the jQuery Migrate test suite in a browser. ```bash npm run test:server ``` -------------------------------- ### Install Dependencies Source: https://github.com/jquery/jquery-migrate/blob/main/CONTRIBUTING.md Install all necessary project dependencies using npm. ```bash npm install ``` -------------------------------- ### Run Tests with npm Test Server Source: https://github.com/jquery/jquery-migrate/blob/main/README.md Start a local test server and access tests via a web browser. Open http://localhost:3000/test/ in your browser. ```sh $ npm run test:server ``` -------------------------------- ### Clone and Build jQuery Migrate Source: https://github.com/jquery/jquery-migrate/blob/main/README.md Clone the repository, navigate into the directory, install dependencies, and build the project using npm. ```sh $ git clone git://github.com/jquery/jquery-migrate.git $ cd jquery-migrate $ npm install $ npm run build ``` -------------------------------- ### Initialize jQuery Migrate with Old jQuery Source: https://github.com/jquery/jquery-migrate/blob/main/test/data/core-jquery3.html This snippet demonstrates the setup for testing jQuery Migrate with an older jQuery version. It uses jQuery.noConflict() to ensure proper initialization. ```javascript jQuery.noConflict(); TestManager.loadProject( "jquery-migrate", "dev", true ); // Should have logged during initialization startIframeTest(); ``` -------------------------------- ### View Test Suite Help Source: https://github.com/jquery/jquery-migrate/blob/main/CONTRIBUTING.md Access the full help documentation for the test suite to explore advanced command-line options. ```bash npm run test:unit -- --help ``` -------------------------------- ### Prepare Tests from Command Line Source: https://github.com/jquery/jquery-migrate/blob/main/CONTRIBUTING.md Prepare the test environment before running the test suite from the command line. ```bash npm run pretest ``` -------------------------------- ### Run Unit Tests from Command Line Source: https://github.com/jquery/jquery-migrate/blob/main/CONTRIBUTING.md Execute the unit test suite directly from the command line, with results reported in the terminal. ```bash npm run test:unit ``` -------------------------------- ### Run Tests with npm Source: https://github.com/jquery/jquery-migrate/blob/main/README.md Execute the test suite using the npm test command. ```sh $ npm test ``` -------------------------------- ### Navigate to Project Directory Source: https://github.com/jquery/jquery-migrate/blob/main/CONTRIBUTING.md Change your current directory to the cloned jQuery Migrate project folder. ```bash cd jquery-migrate ``` -------------------------------- ### Load Projects and Bind Ready Event Source: https://github.com/jquery/jquery-migrate/blob/main/test/data/event-ready.html Loads the necessary jQuery and jQuery-Migrate projects and binds a handler to the document's 'ready' event. This handler is expected to trigger a warning from jQuery Migrate. ```javascript TestManager.loadProject( "jquery", "git" ); jQuery.noConflict(); TestManager.loadProject( "jquery-migrate", "dev", true ); // This should warn when the handler runs jQuery( document ).on( "ready", function() { startIframeTest(); } ); ``` -------------------------------- ### Build jQuery Migrate Files Source: https://github.com/jquery/jquery-migrate/blob/main/CONTRIBUTING.md Compile all jQuery Migrate files for development and testing. ```bash npm run build ``` -------------------------------- ### Load jQuery Migrate Project and Run Tests Source: https://github.com/jquery/jquery-migrate/blob/main/test/index.html Loads the jQuery and jQuery-migrate projects and then initiates the test suite. Ensure jQuery.noConflict() is called before loading migrate to avoid namespace collisions. ```javascript TestManager.loadProject( "jquery", "git.min" ); // Close this script tag so file will load jQuery.noConflict(); TestManager.loadProject( "jquery-migrate", "min", true ); TestManager.loadTests(); ``` -------------------------------- ### Clone jQuery Migrate Repository Source: https://github.com/jquery/jquery-migrate/blob/main/CONTRIBUTING.md Clone your forked jQuery Migrate repository to your local machine to begin development. ```bash git clone git@github.com:username/jquery-migrate.git ``` -------------------------------- ### Checking Document ReadyState for Load Events Source: https://github.com/jquery/jquery-migrate/blob/main/warnings.md If a function depends on all page assets being loaded, check document.readyState. If it's 'complete', run the function immediately. Otherwise, use $(window).on('load', fn). ```javascript if ( document.readyState === "complete" ) { fn(); } else { $( window ).on( "load", fn ); } ``` -------------------------------- ### Enable Watch Task for Auto-Rebuild Source: https://github.com/jquery/jquery-migrate/blob/main/CONTRIBUTING.md Use the watch task to automatically rebuild distribution files whenever a change is saved, avoiding manual rebuilds. ```bash npm start ``` -------------------------------- ### AJAX Request with JSONP Callback Handling Source: https://github.com/jquery/jquery-migrate/blob/main/test/data/ajax-jsonp-callback-name.html Initiates an AJAX request with dataType 'json' and a JSONP callback. It chains subsequent requests and checks for proper callback name management. ```javascript jQuery.ajax( { url: "fakeScript1.js?callback=?", dataType: "json", beforeSend: function( jqXHR, s ) { s.callback = s.jsonpCallback; thisCallbackInWindow1 = this.callback in window; } } ).then( function() { var previous = this; previousJsonpCallback = previous.jsonpCallback; thisCallbackInWindow2 = this.callback in window; return jQuery.ajax( { url: "fakeScript2.js?callback=?", dataType: "json", beforeSend: function() { previousCallback = previous.callback; nextJsonpCallback = this.jsonpCallback; // Test cleanup delete window.customJsonpCallback; } } ); } ).catch( function( _jqXHR, _textStatus, err ) { if ( !( err instanceof Error ) && _jqXHR instanceof Error ) { err = _jqXHR; } // Test cleanup in case of an error delete window.customJsonpCallback; requestSucceeded = false; error = err; } ).then( function() { startIframeTest( thisCallbackInWindow1, thisCallbackInWindow2, previousJsonpCallback, previousCallback, nextJsonpCallback, requestSucceeded, error ); } ); ``` -------------------------------- ### Change Test Server Port Source: https://github.com/jquery/jquery-migrate/blob/main/CONTRIBUTING.md Run the test server on a different port by setting the PORT environment variable. ```bash PORT=3001 npm run test:server ``` -------------------------------- ### jQuery.migrateVersion Source: https://github.com/jquery/jquery-migrate/blob/main/README.md This string property indicates the version of Migrate in use. ```APIDOC ## jQuery.migrateVersion ### Description This string property indicates the version of Migrate in use. ### Property `jQuery.migrateVersion` (string) ``` -------------------------------- ### Add Upstream Remote Source: https://github.com/jquery/jquery-migrate/blob/main/CONTRIBUTING.md Add the main jQuery Migrate repository as an 'upstream' remote to easily pull updates. ```bash git remote add upstream git@github.com:jquery/jquery-migrate.git ``` -------------------------------- ### jQuery.migrateTrace Source: https://github.com/jquery/jquery-migrate/blob/main/README.md Set this property to false to disable stack traces from appearing on the console with warnings. ```APIDOC ## jQuery.migrateTrace ### Description Set this property to `false` if you want warnings but do not want stack traces to appear on the console. ### Property `jQuery.migrateTrace` (boolean) ``` -------------------------------- ### jQuery.migrateIsPatchEnabled Source: https://github.com/jquery/jquery-migrate/blob/main/README.md Returns true if a patch of a provided code is enabled and false otherwise. ```APIDOC ## jQuery.migrateIsPatchEnabled ### Description Returns `true` if a patch of a provided code is enabled and `false` otherwise. ### Method `jQuery.migrateIsPatchEnabled(code: string): boolean` ### Parameters #### Path Parameters - **code** (string) - Required - The code of the patch to check. ``` -------------------------------- ### Load Project and Bind Late Load Event Source: https://github.com/jquery/jquery-migrate/blob/main/test/data/event-lateload.html Loads the jQuery and jQuery-migrate projects and binds a 'load' event handler. This handler is expected to trigger a warning if jQuery Migrate is loaded late. ```javascript TestManager.loadProject( "jquery", "git" ); jQuery.noConflict(); TestManager.loadProject( "jquery-migrate", "dev", true ); var resolve, loaded = new Promise( function ( _resolve ) { resolve = _resolve; } ); // No warning here, document isn't yet loaded jQuery( window ).on( "load", function() { resolve(); }); Promise.all( [ jQuery.ready, loaded ] ).then( function() { // This .on() call should warn jQuery( window ).on( "load", jQuery.noop ); startIframeTest(); } ); ``` -------------------------------- ### HTML5 Doctype for Standards Mode Source: https://github.com/jquery/jquery-migrate/blob/main/warnings.md Ensures the document renders in standards mode, which is required for jQuery compatibility. The simplest valid doctype is the HTML5 one. ```html ``` -------------------------------- ### jQuery.migrateMute Source: https://github.com/jquery/jquery-migrate/blob/main/README.md Set this property to true to prevent console warnings from being generated. The message array is still maintained. ```APIDOC ## jQuery.migrateMute ### Description Set this property to `true` to prevent console warnings from being generated in the development version. The `jQuery.migrateMessages` array is still maintained when this property is set, which allows programmatic inspection without console output. ### Property `jQuery.migrateMute` (boolean) ``` -------------------------------- ### jQuery.migrateMessages Source: https://github.com/jquery/jquery-migrate/blob/main/README.md An array of string warning messages generated by the code on the page, in the order they were generated. Messages appear only once unless reset. ```APIDOC ## jQuery.migrateMessages ### Description This property is an array of string warning messages that have been generated by the code on the page, in the order they were generated. Messages appear in the array only once, even if the condition has occurred multiple times, unless `jQuery.migrateReset()` is called. ### Property `jQuery.migrateMessages` (Array) ``` -------------------------------- ### jQuery.migrateDeduplicateMessages Source: https://github.com/jquery/jquery-migrate/blob/main/README.md By default, Migrate only gives a specific warning once. Set this property to false to give a warning for every occurrence. ```APIDOC ## jQuery.migrateDeduplicateMessages ### Description By default, Migrate only gives a specific warning once. If you set this property to `false` it will give a warning for every occurrence each time it happens. Note that this can generate a lot of output, for example when a warning occurs in a loop. ### Property `jQuery.migrateDeduplicateMessages` (boolean) ``` -------------------------------- ### jQuery.migrateDisablePatches Source: https://github.com/jquery/jquery-migrate/blob/main/README.md Disables patches by their codes. A code for each patch can be found in square brackets in warnings.md. ```APIDOC ## jQuery.migrateDisablePatches ### Description Disables patches by their codes. You can find a code for each patch in square brackets in [warnings.md](https://github.com/jquery/jquery-migrate/blob/main/warnings.md). A limited number of warnings doesn't have codes defined and cannot be disabled. These are mostly setup issues like using an incorrect version of jQuery or loading Migrate multiple times. ### Method `jQuery.migrateDisablePatches(codes: string | string[])` ### Parameters #### Path Parameters - **codes** (string | string[]) - Required - A string or an array of strings representing the patch codes to disable. ``` -------------------------------- ### Include jQuery Migrate Plugin Source: https://github.com/jquery/jquery-migrate/blob/main/README.md Load the jQuery Migrate plugin after the jQuery script tag in your HTML. This ensures jQuery is available before the migrate plugin attempts to modify its behavior. ```html ``` -------------------------------- ### jQuery.migrateReset() Source: https://github.com/jquery/jquery-migrate/blob/main/README.md Clears the jQuery.migrateMessages array and forgets the list of messages that have been seen already. ```APIDOC ## jQuery.migrateReset() ### Description This method clears the `jQuery.migrateMessages` array and "forgets" the list of messages that have been seen already. ### Method `jQuery.migrateReset()` ``` -------------------------------- ### jQuery.UNSAFE_restoreLegacyHtmlPrefilter Source: https://github.com/jquery/jquery-migrate/blob/main/README.md A deprecated alias of jQuery.migrateEnablePatches( "self-closed-tags" ). ```APIDOC ## jQuery.UNSAFE_restoreLegacyHtmlPrefilter ### Description A deprecated alias of `jQuery.migrateEnablePatches( "self-closed-tags" )`. ### Method `jQuery.UNSAFE_restoreLegacyHtmlPrefilter()` ``` -------------------------------- ### Custom AJAX Transport for Script Type Source: https://github.com/jquery/jquery-migrate/blob/main/test/data/ajax-jsonp-callback-name.html Defines a custom AJAX transport for 'script' type requests. This transport intercepts requests to 'fakeScript' URLs and simulates a JSONP response. ```javascript jQuery.ajaxTransport( "script", function( options ) { if ( options.url.indexOf( 'fakeScript' ) === -1 ) { return; } return { abort: function () {}, send: function ( headers, completeCallback ) { var script = options.jsonpCallback + "( { answer: 42 } )"; setTimeout( function() { completeCallback( 200, 'OK', { text: script }, \[\] ); } ); } }; } ); ``` -------------------------------- ### Pull Upstream Changes Source: https://github.com/jquery/jquery-migrate/blob/main/CONTRIBUTING.md Regularly pull changes from the 'upstream' main branch to keep your local repository synchronized. ```bash git pull upstream main ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.