diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml new file mode 100644 index 00000000..2ea1c1cc --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -0,0 +1,57 @@ +name: Bug report +description: Something in jQuery Form does not work as documented. +labels: ["bug"] +body: + - type: markdown + attributes: + value: | + Please search the [open issues](https://github.com/jquery-form/form/issues) first, and see [Reporting a bug](https://github.com/jquery-form/form/blob/main/CONTRIBUTING.md#reporting-a-bug). + Do not report security issues here; see the [security policy](https://github.com/jquery-form/form/blob/main/SECURITY.md). + - type: textarea + id: description + attributes: + label: Description + description: What happened? + validations: + required: true + - type: textarea + id: expected + attributes: + label: Expected behavior + description: What did you expect to happen? + validations: + required: true + - type: textarea + id: steps + attributes: + label: Steps to reproduce + description: The form markup, the options you pass to `ajaxForm` or `ajaxSubmit`, and what you do on the page. + render: html + validations: + required: true + - type: input + id: demo + attributes: + label: Demonstration + description: A link to a minimal example, for instance on [JSFiddle](https://jsfiddle.net/) or [CodePen](https://codepen.io/). + - type: input + id: plugin-version + attributes: + label: jQuery Form version + placeholder: "4.5.0" + validations: + required: true + - type: input + id: jquery-version + attributes: + label: jQuery version + placeholder: "3.7.1" + validations: + required: true + - type: input + id: browsers + attributes: + label: Browsers and versions + placeholder: "Firefox 140, Safari 26" + validations: + required: true diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 00000000..116e8f14 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1,8 @@ +blank_issues_enabled: true +contact_links: + - name: Report a security vulnerability + url: https://github.com/jquery-form/form/security/advisories/new + about: Please report security issues privately, as the security policy (SECURITY.md) describes, not in a public issue. + - name: Documentation + url: https://jquery-form.github.io/form/ + about: The API, options and examples. diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 00000000..adfa20c2 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,29 @@ +version: 2 +updates: + - package-ecosystem: github-actions + directory: / + schedule: + interval: weekly + commit-message: + prefix: ci + groups: + github-actions: + patterns: + - "*" + + # Version updates for the dev tooling only. The jQuery dev dependencies (jquery, jquery4, ...) + # are pinned on purpose: the test matrix runs those exact releases. + - package-ecosystem: npm + directory: / + schedule: + interval: weekly + allow: + - dependency-type: development + ignore: + - dependency-name: "jquery*" + commit-message: + prefix: build + include: scope + groups: + dev-dependencies: + dependency-type: development diff --git a/.github/issue_template.md b/.github/issue_template.md deleted file mode 100644 index 3d33949c..00000000 --- a/.github/issue_template.md +++ /dev/null @@ -1,19 +0,0 @@ -Please review [Instructions for Reporting a Bug](https://github.com/jquery-form/form/blob/main/CONTRIBUTING.md#reporting-a-bug). - -### Description: - -### Expected Behavior: - -### Actual behavior: - -### Versions: - -**LoadJSON:** -**jQuery:** -**Browsers:** - -### Demonstration - -Link to demonstration of issue in [JSFiddle](https://jsfiddle.net/) or [CodePen](https://codepen.io/): - -### Steps to reproduce: diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1e67ca37..8455c294 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -59,22 +59,25 @@ jobs: - name: Get Playwright version id: playwright if: env.CODE == 'true' - run: echo "version=$(node -p "require('playwright/package.json').version")" >> "$GITHUB_OUTPUT" + # The runner image is in the key: a browser cached on one Ubuntu release can miss libraries on the next. + run: | + echo "version=$(node -p "require('playwright/package.json').version")" >> "$GITHUB_OUTPUT" + echo "image=$ImageOS" >> "$GITHUB_OUTPUT" - name: Cache Playwright browsers if: env.CODE == 'true' uses: actions/cache@v6 with: path: ~/.cache/ms-playwright - key: playwright-${{ runner.os }}-${{ steps.playwright.outputs.version }} - - name: Install Chromium + key: playwright-${{ runner.os }}-${{ steps.playwright.outputs.image }}-${{ steps.playwright.outputs.version }} + - name: Install Chromium and WebKit if: env.CODE == 'true' run: | start=$(date +%s) - trap 'printf "%s\t%s\n" "Install Chromium" "$(($(date +%s) - start))" >> "$TIMINGS"' EXIT - npx playwright install chromium + trap 'printf "%s\t%s\n" "Install Chromium and WebKit" "$(($(date +%s) - start))" >> "$TIMINGS"' EXIT + npx playwright install --with-deps chromium webkit - name: Check the test script matches the CI steps run: | - expected="npm run lint && npm run format:check && npm run build && vitest run --coverage" + expected="npm run lint && npm run format:check && npm run build && vitest run --coverage --project !suite-webkit && vitest run --project suite-webkit" actual=$(node -p "require('./package.json').scripts.test") if [ "$actual" != "$expected" ]; then echo "package.json test script has drifted from the CI steps." @@ -103,7 +106,13 @@ jobs: run: | start=$(date +%s) trap 'printf "%s\t%s\n" "vitest run --coverage" "$(($(date +%s) - start))" >> "$TIMINGS"' EXIT - npx vitest run --coverage --reporter=default --reporter=json --outputFile.json=vitest-report.json + npx vitest run --coverage --project !suite-webkit --reporter=default --reporter=json --outputFile.json=vitest-report.json + - name: vitest run --project suite-webkit + if: env.CODE == 'true' + run: | + start=$(date +%s) + trap 'printf "%s\t%s\n" "vitest run --project suite-webkit" "$(($(date +%s) - start))" >> "$TIMINGS"' EXIT + npx vitest run --project suite-webkit - name: Check committed dist matches the build if: env.CODE == 'true' run: | @@ -130,13 +139,15 @@ jobs: # Branch protection requires each matrix check by name, so a docs-only PR skips the steps, not the # job: a job skipped by `if` reports one unexpanded "jQuery ${{ matrix.jquery }}" check instead. jquery: - name: jQuery ${{ matrix.jquery }} + name: jQuery ${{ matrix.jquery }} on ${{ matrix.browser }} needs: changes runs-on: ubuntu-latest timeout-minutes: 10 strategy: fail-fast: false matrix: + browser: [chromium, webkit, firefox] + jquery: ["1.7.2", "3.7.1", "4.0.0"] include: - { jquery: "1.7.2", file: ".jquery/jquery-1.7.2.js" } - { jquery: "3.7.1", file: "node_modules/jquery/dist/jquery.js" } @@ -156,20 +167,69 @@ jobs: - name: Get Playwright version id: playwright if: env.CODE == 'true' - run: echo "version=$(node -p "require('playwright/package.json').version")" >> "$GITHUB_OUTPUT" + # The runner image is in the key: a browser cached on one Ubuntu release can miss libraries on the next. + run: | + echo "version=$(node -p "require('playwright/package.json').version")" >> "$GITHUB_OUTPUT" + echo "image=$ImageOS" >> "$GITHUB_OUTPUT" - name: Cache Playwright browsers if: env.CODE == 'true' uses: actions/cache@v6 with: path: ~/.cache/ms-playwright - key: playwright-${{ runner.os }}-${{ steps.playwright.outputs.version }} - - run: npx playwright install chromium + key: playwright-${{ runner.os }}-${{ steps.playwright.outputs.image }}-${{ steps.playwright.outputs.version }}-${{ matrix.browser }} + - run: npx playwright install --with-deps ${{ matrix.browser }} if: env.CODE == 'true' - name: Fetch jQuery 1.7.2 if: env.CODE == 'true' && matrix.jquery == '1.7.2' run: scripts/fetch-jquery.sh 1.7.2 - name: Run the suite on jQuery ${{ matrix.jquery }} if: env.CODE == 'true' - run: npx vitest run --project suite + run: npx vitest run --project suite-${{ matrix.browser }} + env: + JQUERY_FILE: ${{ matrix.file }} + JQUERY_FORM_FIREFOX: ${{ matrix.browser == 'firefox' && '1' || '' }} + + # End-to-end tests: the built plugin posting to a real server (npm run test:e2e). + # Not a required check, so a docs-only PR can skip the whole job. + e2e: + name: e2e on jQuery ${{ matrix.jquery }} on ${{ matrix.browser }} + needs: changes + if: needs.changes.outputs.code == 'true' + runs-on: ubuntu-latest + timeout-minutes: 10 + strategy: + fail-fast: false + matrix: + browser: [chromium, webkit, firefox] + jquery: ["1.7.2", "3.7.1", "4.0.0"] + include: + - { jquery: "1.7.2", file: ".jquery/jquery-1.7.2.js" } + - { jquery: "3.7.1", file: "node_modules/jquery/dist/jquery.js" } + - { jquery: "4.0.0", file: "node_modules/jquery4/dist/jquery.js" } + steps: + - uses: actions/checkout@v7 + - uses: actions/setup-node@v7 + with: + node-version-file: .nvmrc + cache: npm + - run: npm ci + - name: Get Playwright version + id: playwright + # The runner image is in the key: a browser cached on one Ubuntu release can miss libraries on the next. + run: | + echo "version=$(node -p "require('playwright/package.json').version")" >> "$GITHUB_OUTPUT" + echo "image=$ImageOS" >> "$GITHUB_OUTPUT" + - name: Cache Playwright browsers + uses: actions/cache@v6 + with: + path: ~/.cache/ms-playwright + key: playwright-${{ runner.os }}-${{ steps.playwright.outputs.image }}-${{ steps.playwright.outputs.version }}-${{ matrix.browser }} + - run: npx playwright install --with-deps ${{ matrix.browser }} + - name: Fetch jQuery 1.7.2 + if: matrix.jquery == '1.7.2' + run: scripts/fetch-jquery.sh 1.7.2 + - name: Run the end-to-end tests on jQuery ${{ matrix.jquery }} + run: npm run test:e2e -- --project ${{ matrix.browser }} env: JQUERY_FILE: ${{ matrix.file }} + JQUERY_FORM_FIREFOX: ${{ matrix.browser == 'firefox' && '1' || '' }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 01add7b0..ef6c9cb7 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -28,13 +28,17 @@ jobs: - run: npm ci - name: Get Playwright version id: playwright - run: echo "version=$(node -p "require('playwright/package.json').version")" >> "$GITHUB_OUTPUT" + # The runner image is in the key: a browser cached on one Ubuntu release can miss libraries on the next. + run: | + echo "version=$(node -p "require('playwright/package.json').version")" >> "$GITHUB_OUTPUT" + echo "image=$ImageOS" >> "$GITHUB_OUTPUT" - name: Cache Playwright browsers uses: actions/cache@v6 with: path: ~/.cache/ms-playwright - key: playwright-${{ runner.os }}-${{ steps.playwright.outputs.version }} - - run: npx playwright install chromium + key: playwright-${{ runner.os }}-${{ steps.playwright.outputs.image }}-${{ steps.playwright.outputs.version }} + # npm test runs the suite in Chromium and WebKit; WebKit needs its system libraries. + - run: npx playwright install --with-deps chromium webkit - run: npm test - name: Check committed dist matches the build run: git diff --exit-code -- dist diff --git a/.gitignore b/.gitignore index f739e41e..19e9302c 100644 --- a/.gitignore +++ b/.gitignore @@ -231,4 +231,7 @@ $RECYCLE.BIN/ ### Build and test output ### coverage/ .vitest/ +test-results/ +playwright-report/ .jquery/ +.pack/ diff --git a/.prettierignore b/.prettierignore index fcd7019c..81650e91 100644 --- a/.prettierignore +++ b/.prettierignore @@ -10,3 +10,6 @@ package-lock.json prototype/ test/ajax/ test/img/ +playwright-report/ +test-results/ +.pack/ diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 098294a3..fdb88ee4 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -3,7 +3,7 @@ Want to contribute to jQuery Form? That's great! Contributions are most welcome! Here are a couple of guidelines that will help you contribute. Before we get started: Please note that this project is released with a [Contributor Code of Conduct](CODE_OF_CONDUCT.md) to ensure that this project is a welcoming place for **everyone** to contribute to. By participating in this project you agree to abide by its terms. -#### Overview +## Overview * [Contribution workflow](#contribution-workflow) * [Branching and releases](#branching-and-releases) @@ -16,33 +16,37 @@ Here are a couple of guidelines that will help you contribute. Before we get sta ## Contribution workflow 1. Fork the repository in GitHub with the `Fork` button. -2. Branch from **`main`** into a short-lived topic branch (e.g. `new-feature`): - `git checkout -b new-feature` +2. Branch from **`main`** into a short-lived topic branch (e.g. `new-feature`): + + ```shell + git checkout -b new-feature + ``` + 3. Make your feature addition or bug fix. -4. After setting up your [testing enviroment](#testing), run the tests: +4. After setting up your [testing environment](#testing), run the tests: - ```shell - npm test - ``` + ```shell + npm test + ``` - If the tests all pass, move on to step 5. + If the tests all pass, move on to step 5. 5. Open a pull request **against `main`**. Topic branches only—do not PR into long-lived integration branches that no longer exist (`develop`, etc.). - * Please make sure all of your commits are atomic (one feature per commit). - * Use sensible commit messages. - * Always write a clear log message for your commits. One-line messages are fine for small changes, but bigger changes should look like this: - ```shell - $ git commit -m "A brief summary of the commit" - > - > A paragraph describing what changed and its impact." - ``` - * If your PR fixes a separate issue number, include it in the commit message. + * Please make sure all of your commits are atomic (one feature per commit). + * Use sensible commit messages. + * Always write a clear log message for your commits. One-line messages are fine for small changes, but bigger changes should look like this: + + ```shell + git commit -m "A brief summary of the commit" -m "A paragraph describing what changed and its impact." + ``` + + * If your PR fixes a separate issue number, include it in the commit message. ### Things to keep in mind * Smaller PRs are likely to be merged more quickly than bigger changes. * Every merge needs maintainer review. -* This project is using [Semantic Versioning 2.0.0](http://semver.org/) +* This project is using [Semantic Versioning 2.0.0](https://semver.org/) ## Branching and releases @@ -60,19 +64,44 @@ jQuery Form uses [Node.js](https://nodejs.org/), [Rollup](https://rollupjs.org/) 1. Install the [Node.js](https://nodejs.org/) version in `.nvmrc` (with nvm: `nvm use`). 2. Install dependencies and the test browser: - ```shell - npm ci - npx playwright install chromium - ``` + ```shell + npm ci + npx playwright install chromium + ``` 3. Run lint, the build, and the tests: - ```shell - npm test - ``` + ```shell + npm test + ``` Edit `src/jquery.form.js` (an ES module), never `dist/`. `npm test` rebuilds `dist/`; commit the rebuilt files with your change, since CI fails if they differ from the build. +### End-to-end tests + +`npm run test:e2e` runs [Playwright Test](https://playwright.dev/) against the built `dist/jquery.form.js` (run `npm run build` first) on Chromium and WebKit. A small Node server (`test/e2e/server.mjs`) serves the fixture page and records every request the plugin sends, through each transport (urlencoded and FormData XHR, the iframe upload). Each test submits the same form natively and through the plugin, and the two requests must match after parsing, apart from the known differences listed in `test/shared/oracle-forms.js` and `test/e2e/harness.js`. `npm test` does not run them. + +It first tests the package as npm would publish it: `scripts/pack-fixture.mjs` runs `npm pack` and installs the tarball into fixture projects under `.pack/` (one per jQuery version, installed from the registry or npm's cache). `test/e2e/published-node.test.mjs` (`node --test`) loads it by name from CommonJS and ES modules in Node, with jsdom as the window, and `test/e2e/published.spec.mjs` loads it in the browser by script tag (plain and minified), RequireJS and an import map, then posts a form over XHR and uploads a file through the iframe. Set `JQUERY_FORM_TARBALL` to test a tarball you packed elsewhere. + +Set `JQUERY_FILE` to test another jQuery build, as for the suite. `npm run test:e2e:docker` runs them in Docker on all three browsers, including Firefox. + +### Running tests in Docker + +Playwright's Firefox build does not start on some macOS versions, and `npm test` covers only Chromium and WebKit. To run the suite on Firefox (or on all three browsers under Linux), use Docker. The scripts use the Playwright image that matches the `playwright` version in `package.json` and leave your local `node_modules` untouched: + +```shell +npm run test:firefox # the suite on Firefox +npm run test:docker # the suite on Chromium, WebKit and Firefox +``` + +`scripts/test-docker.sh` passes any arguments on to `vitest run` (or to `playwright test` after `--e2e`). To test another jQuery build, set `JQUERY_FILE`, e.g. `JQUERY_FILE=.jquery/jquery-1.7.2.js npm run test:firefox` (fetch it first with `scripts/fetch-jquery.sh 1.7.2`). + +Node and `node_modules` are cached in Docker volumes (`jquery-form-node`, and `jquery-form-node-modules-` for each `package-lock.json`). To clear them: + +```shell +docker volume rm jquery-form-node $(docker volume ls -q --filter name=jquery-form-node-modules-) +``` + ### Git blame Repo-wide formatting commits are listed in [`.git-blame-ignore-revs`](.git-blame-ignore-revs). To skip them in `git blame`: diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 9995b4fd..3831e2fa 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -1,10 +1,12 @@ -#Contributors +# Contributors + +## Copyright 2017 Kevin Morris -###Copyright 2017 Kevin Morris Continuing Work [jQuery Form](https://github.com/jquery-form/form/) by Kevin Morris Project Home: [github.com/jquery-form/form](https://github.com/jquery-form/form/) -###Copyright 2006-2014 Mike Alsup +## Copyright 2006-2014 Mike Alsup + Original work [jQuery Form](https://github.com/malsup/form/) by Mike Alsup -Project Home: [jquery.malsup.com/form](http://jquery.malsup.com/form/) +Project Home: [malsup.com/jquery/form](https://malsup.com/jquery/form/) The jQuery Form Plugin allows you to easily and unobtrusively upgrade HTML forms to use AJAX. diff --git a/README.md b/README.md index 0c06157b..8f96dcfd 100644 --- a/README.md +++ b/README.md @@ -5,258 +5,91 @@ The jQuery Form Plugin allows you to easily and unobtrusively upgrade HTML forms No special markup is needed, just a normal form. Submitting a form with AJAX doesn't get any easier than this! -## Community -Want to contribute to jQuery Form? Awesome! See [CONTRIBUTING](CONTRIBUTING.md) for more information. - -### Code of Conduct -Please note that this project is released with a [Contributor Code of Conduct](CODE_OF_CONDUCT.md) to ensure that this project is a welcoming place for **everyone** to contribute to. By participating in this project you agree to abide by its terms. +**Documentation:** [jquery-form.github.io/form](https://jquery-form.github.io/form/), with the [API](https://jquery-form.github.io/form/api/), the [options](https://jquery-form.github.io/form/options/) and [examples](https://jquery-form.github.io/form/examples/). -### Security -Please report security issues privately, not in public issues. See [SECURITY](SECURITY.md). - -Some options must be trusted input only, and a `target` response is inserted as HTML; see [Trusted options](docs/options.md#trusted-options) and the [`target`](docs/options.md#target) sanitizing recipe. Iframe uploads need HTML-safe responses; see [`iframe`](docs/options.md#iframe). +## Installation +```sh +npm install jquery-form +``` -## Compatibility -* Requires jQuery 1.7.2 or later. `main` is tested against jQuery 1.7.2, 3.7.1 and 4.0.0. -* jQuery 4 needs 4.4.0 or later; 4.3.0 uses APIs that jQuery 4 removed. -* With `delegation: true` on jQuery 3 and later, every form on the page is handled, not only the selected ones; use `delegation: ""` instead. ([issue #353](https://github.com/jquery-form/form/issues/353)) -* **Not** compatible with the jQuery slim builds, which leave out AJAX. +jQuery is a dependency of the package and is installed with it. ## Download -* **Development:** [dist/jquery.form.js -](https://github.com/jquery-form/form/blob/main/dist/jquery.form.js) -* **Production/Minified:** [dist/jquery.form.min.js -](https://github.com/jquery-form/form/blob/main/dist/jquery.form.min.js) +* **npm:** [jquery-form](https://www.npmjs.com/package/jquery-form). `dist/jquery.form.min.js` is the minified build, `dist/jquery.form.js` the readable one. +* **GitHub:** each version's built files are in the `dist` folder of its tag, such as [`v4.6.0/dist`](https://github.com/jquery-form/form/tree/v4.6.0/dist); see the [releases](https://github.com/jquery-form/form/releases). The `dist` folder on `main` holds unreleased code. ### CDN +From jsDelivr: + ```html - + ``` ---- - -## API - -### jqXHR -The jqXHR object is stored in element data-cache with the jqxhr key after each ajaxSubmit -call. It can be accessed like this: +Or from cdnjs: -````javascript -var form = $('#myForm').ajaxSubmit({ /* options */ }); -var xhr = form.data('jqxhr'); - -xhr.done(function() { -... -}); -```` - -### ajaxForm( options ) -Prepares a form to be submitted via AJAX by adding all of the necessary event listeners. It does **not** submit the form. Use `ajaxForm` in your document's `ready` function to prepare existing forms for AJAX submission, or with the `delegation` option to handle forms not yet added to the DOM. -Use ajaxForm when you want the plugin to manage all the event binding for you. - -````javascript -// prepare all forms for ajax submission -$('form').ajaxForm({ - target: '#myResultsDiv' -}); -```` - -### ajaxFormUnbind( [selector] ) -Removes the handlers `ajaxForm` bound on the selection, and every delegated binding (`delegation: true` or a selector) the plugin made on the document. With a selector string it removes only that delegated binding and leaves the selection's handlers alone. Calling `ajaxForm` again on a form does not remove delegated bindings. - -````javascript -$('#myForm').ajaxFormUnbind(); // the form's handlers and all delegated bindings -$(document).ajaxFormUnbind('form.ajax'); // one delegated binding -```` - -### ajaxSubmit( options ) -Immediately submits the form via AJAX. In the most common use case this is invoked in response to the user clicking a submit button on the form. -Use ajaxSubmit if you want to bind your own submit handler to the form. - -````javascript -// bind submit handler to form -$('form').on('submit', function(e) { - e.preventDefault(); // prevent native submit - $(this).ajaxSubmit({ - target: '#myResultsDiv' - }) -}); -```` - ---- - -## Options -**Note:** All standard [$.ajax](http://api.jquery.com/jQuery.ajax) options can be used. - -### beforeSerialize -Callback function invoked before form serialization. Provides an opportunity to manipulate the form before its values are retrieved. Returning `false` from the callback will prevent the form from being submitted. The callback is invoked with two arguments: the jQuery wrapped form object and the options object. - -````javascript -beforeSerialize: function($form, options) { - // return false to cancel submit -} -```` - -### beforeSubmit -Callback function invoked before form submission. Returning `false` from the callback will prevent the form from being submitted. The callback is invoked with three arguments: the form data in array format, the jQuery wrapped form object, and the options object. - -````javascript -beforeSubmit: function(arr, $form, options) { - // form data array is an array of objects with name and value properties - // [ { name: 'username', value: 'jresig' }, { name: 'password', value: 'secret' } ] - // return false to cancel submit -} -```` - -### beforeFormUnbind -Callback function invoked before form events unbind and bind again. Provides an opportunity to manipulate the form before events will be remounted. The callback is invoked with two arguments: the jQuery wrapped form object and the options object. - -````javascript -beforeFormUnbind: function($form, options) { - // your callback code -} -```` - -### filtering -Callback function invoked before processing fields. This provides a way to filter elements. +```html + +``` -````javascript -filtering: function(el, index) { - if ( !$(el).hasClass('ignore') ) { - return el; - } -} -```` +## Usage +With a script tag, load the plugin after jQuery: -### clearForm -Boolean flag indicating whether the form should be cleared if the submit is successful +```html + + +``` -### data -An object containing extra data that should be submitted along with the form. +With a bundler, importing the module registers the plugin on the jQuery that `import "jquery"` resolves to, so `jquery` must be importable: -```` -data: { key1: 'value1', key2: 'value2' } -```` +```javascript +import $ from "jquery"; +import "jquery-form"; +``` -### dataType -Expected data type of the response. One of: null, 'xml', 'script', or 'json'. The dataType option provides a means for specifying how the server response should be handled. This maps directly to jQuery's dataType method. The following values are supported: +With CommonJS, the package exports a factory that takes the window and jQuery, registers the plugin and returns jQuery: -* 'xml': server response is treated as XML and the 'success' callback method, if specified, will be passed the responseXML value -* 'json': server response will be evaluated and passed to the 'success' callback, if specified -* 'script': server response is evaluated in the global context +```javascript +var $ = require("jquery"); +require("jquery-form")(window, $); +``` -### delegation -A selector string, or `true`, to handle forms through a document-level (delegated) binding, so forms added later are handled too. -*requires jQuery v1.7+* +AMD loaders get the plugin as a module that depends on `jquery`. -With a selector, a form is submitted through the plugin when it, or an element around it, matches the selector. The selection `ajaxForm` is called on is ignored. Binding the same selector again replaces its options. An empty string throws an error. +Then prepare a form, and it is submitted with AJAX: -````javascript -// prepare existing and future forms with class "ajax" for ajax submission -$(document).ajaxForm({ - delegation: 'form.ajax' +```javascript +$(function () { + $("#myForm").ajaxForm({ + target: "#output", + success: function () { + alert("Thank you for your comment!"); + }, + }); }); -```` - -**Warning:** `delegation: true` uses the selection's selector, which jQuery 3.0 removed. On jQuery 3 and later it binds **every form on the page**, so the options (`data`, `headers`) go with any form's submission. The plugin logs a `console.warn` for each such call, even with `debug` off. Use a selector. jQuery 5.0 support will require one. - -### error -Callback function to be invoked upon error. It is passed the following arguments: - -1. `jqXHR`, object (the error response body is in `responseText`) -2. `textStatus`, string -3. `errorThrown`, string -4. `$form` jQuery object containing form element - -### forceSync -Only applicable when explicity using the iframe option or when uploading files on browsers that don't support XHR2. -Set to `true` to remove the short delay before posting form when uploading files. The delay is used to allow the browser to render DOM updates before performing a native form submit. This improves usability when displaying notifications to the user, such as "Please Wait..." - -### iframe -Boolean flag indicating whether the form should *always* target the server response to an iframe instead of leveraging XHR when possible. - -### iframeSrc -String value that should be used for the iframe's src attribute when an iframe is used. - -### iframeTarget -Identifies the iframe element to be used as the response target for file uploads. By default, the plugin will create a temporary iframe element to capture the response when uploading files. This option allows you to use an existing iframe if you wish. When using this option the plugin will not attempt handling the response from the server. - -### method -The HTTP method to use for the request (e.g. 'POST', 'GET', 'PUT'). - -### replaceTarget -Optionally used along with the target option. Set to true if the target should be replaced or false if only the target contents should be replaced. - -### requestFormat -Set to `"json"` to send the fields (repeated names as arrays) merged with object `data` as a JSON body, with `contentType: "application/json; charset=UTF-8"`. Throws with a GET method, string `data`, files or the iframe transport. Based on the idea in PR #557 by zhangciwu. - -### resetForm -Boolean flag indicating whether the form should be reset if the submit is successful - -### semantic -Boolean flag indicating whether data must be submitted in strict semantic order (slower). Note that the normal form serialization is done in semantic order except for input elements of `type="image"`. You should only set the semantic option to true if your server has strict semantic requirements and your form contains an input element of `type="image"`. - -### success -Callback function to be invoked after the form has been submitted. If a 'success' callback function is provided it is invoked after the response has been returned from the server. It is passed the following standard jQuery arguments: - -1. `data`, formatted according to the dataType parameter or the dataFilter callback function, if specified -2. `textStatus`, string -3. `jqXHR`, object -4. `$form` jQuery object containing form element - -### target -Identifies the element(s) in the page to be updated with the server response. This value may be specified as a jQuery selection string, a jQuery object, or a DOM element. - -### type -The HTTP method to use for the request (e.g. 'POST', 'GET', 'PUT'). -An alias for `method` option. Overridden by the `method` value if both are present. - -### uploadProgress -Callback function to be invoked with upload progress information (if supported by the browser). The callback is passed the following arguments: - -1. event; the browser event -2. position (integer) -3. total (integer) -4. percentComplete (integer) - -### url -URL to which the form data will be submitted. - ---- - -## Utility Methods -### formSerialize -Serializes the form into a query string. This method will return a string in the format: `name1=value1&name2=value2` - -````javascript -var queryString = $('#myFormId').formSerialize(); -```` - -### fieldSerialize -Serializes field elements into a query string. This is handy when you need to serialize only part of a form. This method will return a string in the format: `name1=value1&name2=value2` - -````javascript -var queryString = $('#myFormId .specialFields').fieldSerialize(); -```` +``` -### fieldValue -Returns the value(s) of the element(s) in the matched set in an array. This method always returns an array. If no valid value can be determined the array will be empty, otherwise it will contain one or more values. +`ajaxForm` binds the form so that it submits with AJAX; `ajaxSubmit` submits it now, from your own submit handler. The [API](https://jquery-form.github.io/form/api/) page describes every method, and the [options](https://jquery-form.github.io/form/options/) page every option. -### resetForm -Resets the form to its original state by invoking the form element's native DOM method. +## File Uploads +A form with a selected file, or a `multipart/form-data` enctype, is sent with [FormData](https://developer.mozilla.org/en-US/docs/Web/API/FormData) over [XMLHttpRequest](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest), and the `uploadProgress` option reports progress as the upload proceeds. With `iframe: true`, the form is posted through a hidden iframe instead, which needs the server to return HTML-safe responses; see [`iframe`](https://jquery-form.github.io/form/options/#iframe). -### clearForm -Clears the form elements. This method empties all of the text inputs, password inputs and textarea elements, clears the selection in any select elements, and unchecks all radio and checkbox inputs. It does *not* clear hidden field values. +## Compatibility +* Requires jQuery 1.7.2 or later. `main` is tested against jQuery 1.7.2, 3.7.1 and 4.0.0, on Chromium, Firefox and WebKit. +* jQuery 4 needs 4.4.0 or later; 4.3.0 uses APIs that jQuery 4 removed. +* With `delegation: true` on jQuery 3 and later, every form on the page is handled, not only the selected ones; use `delegation: ""` instead. ([issue #353](https://github.com/jquery-form/form/issues/353)) +* **Not** compatible with the jQuery slim builds, which leave out AJAX. +* 5.0 will need jQuery 3.5 or later. With debug output on (`$.fn.ajaxSubmit.debug = true`), 4.x warns about the features 5.0 removes; see [Deprecations](https://jquery-form.github.io/form/api/#deprecations) and [issue #629](https://github.com/jquery-form/form/issues/629). -### clearFields -Clears selected field elements. This is handy when you need to clear only a part of the form. +## Security +Please report security issues privately, not in public issues. See [SECURITY](SECURITY.md). ---- +Some options must be trusted input only, and a `target` response is inserted as HTML; see [Trusted options](https://jquery-form.github.io/form/options/#trusted-options) and the [`target`](https://jquery-form.github.io/form/options/#target) sanitizing recipe. Iframe uploads need HTML-safe responses; see [`iframe`](https://jquery-form.github.io/form/options/#iframe). -## File Uploads -The Form Plugin supports the use of [XMLHttpRequest Level 2]("http://www.w3.org/TR/XMLHttpRequest/") and [FormData](https://developer.mozilla.org/en/XMLHttpRequest/FormData) objects on browsers that support these features. As of today (March 2012) that includes Chrome, Safari, and Firefox. On these browsers (and future Opera and IE10) files uploads will occur seamlessly through the XHR object and progress updates are available as the upload proceeds. For older browsers, a fallback technology is used which involves iframes. [More Info](http://malsup.com/jquery/form/#file-upload) +## Community +Want to contribute to jQuery Form? Awesome! See [CONTRIBUTING](CONTRIBUTING.md) for more information. ---- +### Code of Conduct +Please note that this project is released with a [Contributor Code of Conduct](CODE_OF_CONDUCT.md) to ensure that this project is a welcoming place for **everyone** to contribute to. By participating in this project you agree to abide by its terms. ## Contributors This project has transferred from [github.com/malsup/form](https://github.com/malsup/form/), courtesy of [Mike Alsup](https://github.com/malsup). @@ -268,7 +101,3 @@ This project is dual-licensed under the LGPLv2.1 (or later) or MIT licenses: * [GNU Lesser General Public License v2.1](LICENSE) * [MIT](LICENSE-MIT) - ---- - -Additional documentation and examples for version 3.51- at: [http://malsup.com/jquery/form/](http://malsup.com/jquery/form/) diff --git a/SECURITY.md b/SECURITY.md index 570dafbd..1a48aa24 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -18,4 +18,3 @@ Report them privately through GitHub: open the repository's **Security** tab and Include the plugin and jQuery versions, the options used, and a minimal reproduction. Reporters are credited in the advisory unless they ask not to be. - diff --git a/_config.yml b/_config.yml deleted file mode 100644 index 72d781d7..00000000 --- a/_config.yml +++ /dev/null @@ -1 +0,0 @@ -theme: jekyll-theme-tactile diff --git a/bower.json b/bower.json index 8f386b29..94f9593d 100644 --- a/bower.json +++ b/bower.json @@ -3,7 +3,7 @@ "description": "The jQuery Form Plugin allows you to easily and unobtrusively upgrade HTML forms to use AJAX.", "main": "dist/jquery.form.js", "moduleType": ["globals", "amd", "node"], - "license": "(LGPL-2.1+ OR MIT)", + "license": "(LGPL-2.1-or-later OR MIT)", "ignore": ["README.md", "composer.json", "package.json"], "keywords": [ "jquery", @@ -16,7 +16,7 @@ "jquery-form" ], "authors": [{ "name": "Kevin Morris" }, { "name": "Mike Alsup" }], - "homepage": "https://github.com/jquery-form/form", + "homepage": "https://jquery-form.github.io/form/", "repository": { "type": "git", "url": "https://github.com/jquery-form/form.git" diff --git a/composer.json b/composer.json index 05427254..bc78e503 100644 --- a/composer.json +++ b/composer.json @@ -11,8 +11,8 @@ "form", "jquery-form" ], - "homepage": "https://github.com/jquery-form/form", - "license": "(LGPL-2.1+ OR MIT)", + "homepage": "https://jquery-form.github.io/form/", + "license": "(LGPL-2.1-or-later OR MIT)", "authors": [ { "name": "Kevin Morris" diff --git a/dist/jquery.form.js b/dist/jquery.form.js index 04b82546..eb1af99a 100644 --- a/dist/jquery.form.js +++ b/dist/jquery.form.js @@ -1,6 +1,6 @@ /*! * jQuery Form Plugin - * version: 4.5.0 + * version: 4.6.0 * Requires jQuery v1.7.2 or later * Project repository: https://github.com/jquery-form/form @@ -23,7 +23,9 @@ (function (factory) { if (typeof define === 'function' && define.amd) { // AMD. Register as an anonymous module. - define(['jquery'], factory); + define(['jquery'], function (jQuery) { + factory(jQuery, window); + }); } else if (typeof module === 'object' && module.exports) { // Node/CommonJS module.exports = function( root, jQuery ) { @@ -37,16 +39,19 @@ jQuery = require('jquery')(root); } } - factory(jQuery); + factory(jQuery, root || (typeof window !== 'undefined' ? window : undefined)); return jQuery; }; } else { // Browser globals - factory(jQuery); + factory(jQuery, window); } -}(function (jQuery) { +}(function (jQuery, root) { 'use strict'; + var window = root; + var document = window.document, navigator = window.navigator; + var Element = window.Element, FormData = window.FormData; // Form members: the properties and methods the plugin reads or calls on a form. A control named // like a member (elements, setAttribute) shadows that member on the form itself, so members are // read through the DOM prototypes, which a control cannot shadow. @@ -104,6 +109,14 @@ function tagName(el) { return typeof name === "string" ? name.toLowerCase() : ""; } +/** + * Whether a control or option is disabled, also through a disabled fieldset or optgroup. Without + * selector matching, only its own disabled property is read. + */ +function isDisabled(el) { + return typeof el.matches === "function" ? el.matches(":disabled") : !!el.disabled; +} + // Elements only: the subject of formToArray may also be the document or a plain object. function isElement(node) { return formMember(node, "nodeType") === 1; @@ -250,7 +263,8 @@ function submitterFields(form) { var sub = submitterOf(form); var el = sub && sub.el; - if (el && el.name && !el.disabled) { + // a disabled button is not sent, also when a disabled fieldset disables it + if (el && el.name && !isDisabled(el)) { fields[el.name] = el.value; if (el.type === "image") { fields[el.name + ".x"] = sub.x; @@ -387,6 +401,25 @@ function keepContext(settings, sources) { return settings; } +/** + * The elements a selector option (target, iframeTarget) names. A string is only ever a selector, + * looked up in the document, so jQuery never builds elements from it; a string starting with "<" + * is HTML, not a selector, and matches nothing. Elements and jQuery objects are used as given. + */ +function selectorOption(value, ownerDocument) { + if (typeof value !== "string") { + return jQuery(value); + } + + if (/^\s*= 200 && xhr.status < 300) || xhr.status === 304)) { + if (status === "parsererror") { + errMsg = undefined; + } status = "error"; } @@ -1493,7 +1612,7 @@ function createLifecycle(s, frame) { if (s.error) { s.error.call(s.context, xhr, status, errMsg); } - deferred.reject(xhr, "error", errMsg); + deferred.reject(xhr, status, errMsg); if (g) { $$1.event.trigger("ajaxError", [xhr, s, errMsg]); } @@ -1567,7 +1686,7 @@ function createIframeTransport(hasProp, forms) { var $io, n; if (s.iframeTarget) { - $io = $(s.iframeTarget, ownerDocument); + $io = selectorOption(s.iframeTarget, ownerDocument); n = $io.attr("name"); if (!n) { $io.attr("name", id); @@ -1889,7 +2008,7 @@ function createSubmission(feature, forms, serialization) { options.extraData = optionsData; - return $.param(optionsData, traditional); + return $.param(wellFormedData(optionsData), traditional); } // Sets a key as an own data property, so a name like __proto__ is an ordinary key. @@ -2053,7 +2172,7 @@ function createSubmission(feature, forms, serialization) { if (options.requestFormat === "json") { jsonBody(options, fields); } else { - encode(options, $.param(urlencodedFields(fields), traditional), qx); + encode(options, urlencode(fields, traditional), qx); } return { @@ -2096,7 +2215,7 @@ function createSubmission(feature, forms, serialization) { callbacks.push(function (data, textStatus, jqXHR) { var successArguments = arguments, fn = options.replaceTarget ? "replaceWith" : "html", - $target = $(options.target); + $target = selectorOption(options.target); // Only a string response is inserted. jQuery has already parsed a JSON or XML response, // and inserting it would parse each of its strings as HTML. @@ -2364,7 +2483,7 @@ function createSubmission(feature, forms, serialization) { */ $.fn.formSerialize = function (semantic) { // hand off to jQuery.param for proper encoding - return $.param(urlencodedFields(this.formToArray(semantic))); + return urlencode(this.formToArray(semantic)); }; /** @@ -2374,6 +2493,8 @@ function createSubmission(feature, forms, serialization) { $.fn.fieldSerialize = function (successful) { var a = []; + deprecateFieldValueOverride(); + this.each(function () { var n = this.name; @@ -2394,7 +2515,7 @@ function createSubmission(feature, forms, serialization) { }); // hand off to jQuery.param for proper encoding - return $.param(a); + return urlencode(a); }; /** @@ -2457,15 +2578,7 @@ function createSubmission(feature, forms, serialization) { /** * Returns the value of the field element. */ - $.fieldValue = function (el, successful) { - var required = typeof successful === "undefined" || successful; - - if (required && !isSuccessful(el, submitterElement(el.form))) { - return null; - } - - return valueOf(el); - }; + $.fieldValue = fieldValue; /** * Clears the form data. Takes the following actions on the form's input fields: diff --git a/dist/jquery.form.min.js b/dist/jquery.form.min.js index 6a5c91c1..68d39c12 100644 --- a/dist/jquery.form.min.js +++ b/dist/jquery.form.min.js @@ -1,6 +1,6 @@ /*! * jQuery Form Plugin - * version: 4.5.0 + * version: 4.6.0 * Requires jQuery v1.7.2 or later * Project repository: https://github.com/jquery-form/form @@ -19,5 +19,5 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. */ -!function(e){"function"==typeof define&&define.amd?define(["jquery"],e):"object"==typeof module&&module.exports?module.exports=function(t,r){return void 0===r&&(r="undefined"!=typeof window?require("jquery"):require("jquery")(t)),e(r),r}:e(jQuery)}(function(e){"use strict";var t=["HTMLFormElement","HTMLElement","Element","Node"],r=document.createElement("form");function n(e){for(var r=0;r=0)return r;return null}var l="jqFormSubmitter";function f(e,t,r){try{e[t]=r}catch(e){}}function d(e,t){var r=e[t],n=a(e,"elements");return n&&r&&n.namedItem(t)===r?void 0:r}function p(t,r,n,a){e.data(t,l,{el:r,x:n,y:a}),f(t,"clk",r),"image"===r.type&&(f(t,"clk_x",n),f(t,"clk_y",a)),setTimeout(function(){e.data(t,l,null),f(t,"clk",null),f(t,"clk_x",null),f(t,"clk_y",null)},100)}function m(t){var r=c(t.target,["button","input"]);if(r&&("submit"===r.type||"image"===r.type)){var n=r.form;if(n){var a="image"===r.type?function(t,r){if(void 0!==t.offsetX)return[t.offsetX,t.offsetY];if("function"==typeof e.fn.offset){var n=e(r).offset();return[t.pageX-n.left,t.pageY-n.top]}return[t.pageX-r.offsetLeft,t.pageY-r.offsetTop]}(t,r):[];p(n,r,a[0],a[1])}}}function v(t){if(!t)return null;var r=e.data(t,l);if(r)return r;var n=d(t,"clk");return n?{el:n,x:d(t,"clk_x"),y:d(t,"clk_y")}:null}function h(){if(e.fn.ajaxSubmit.debug){var t="[jquery.form] "+Array.prototype.join.call(arguments,"");window.console&&window.console.log?window.console.log(t):window.opera&&window.opera.postError&&window.opera.postError(t)}}var g={};function y(t,r){e.fn.ajaxSubmit.debug&&!g[t]&&(g[t]=!0,window.console&&"function"==typeof window.console.warn&&window.console.warn("[jquery.form] "+r+" (removed in 5.0)"))}function b(e){(function(e){var t=String(e).split("."),r=Number(t[0]);return r<3||3===r&&Number(t[1])<5})(e)&&y("jquery","support for jQuery "+e+" is deprecated, 5.0 needs jQuery 3.5 or later")}function x(e,t,r,n){if("string"!=typeof e&&!1!==e)return e;var a={url:e,data:t,dataType:r};return"function"==typeof n&&(a.success=n),a}function j(e,t,r,n){return"function"==typeof e?{success:e}:void 0===(e=x(e,t,r,n))?{}:!1===e.url||""===e.url?function(e){var t={};for(var r in e)"url"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t}(e):e}function w(e,t){for(var r=0;r"'),e(function(){e(n.s,n.c).ajaxForm(r)}),t):(h("terminating; zero elements found by selector"+(e.isReady?"":" (DOM not ready)")),t)}(this,t))}function L(t){return"string"==typeof t?(D(t),this):(t!==A&&(q={},e(document).off("submit.form-plugin click.form-plugin")),this.off("submit.form-plugin click.form-plugin"))}function M(t,r){if(!u(t))return e(t).attr(r);var n=o(t,"getAttribute",r);return null===n?void 0:n}var N=/\r\n|\r|\n/g,C=/\r/g,I=/^(?:fieldset|object|output)$/;function $(e){return"function"==typeof e.matches?e.matches(":disabled"):!!e.disabled}function P(t){if("select"===i(t))return function(e){var t=e.selectedIndex;if(t<0)return null;for(var r=[],n=e.options,a="select-one"===e.type,o=a?t+1:n.length,i=a?t:0;i=0,o=a?e.responseXML:e.responseText;return a&&"parsererror"===o.documentElement.nodeName&&J.error&&J.error("parsererror"),r&&r.dataFilter&&(o=r.dataFilter(o,t)),"string"==typeof o&&(("json"===t||!t)&&n.indexOf("json")>=0?o=JSON.parse(o):"script"===t&&J.globalEval(o)),o}(t,s,r)}catch(e){i="parsererror",t.error=o=e||i}}catch(e){h("error caught: ",e),i="error",t.error=o=e}return{status:i,data:a,errMsg:o}}var re=e;function ne(e,t){var r,n,a,o=re.Deferred(),i={aborted:0,responseText:null,responseXML:null,status:0,statusText:"n/a",getAllResponseHeaders:function(){},getResponseHeader:function(){},setRequestHeader:function(){},abort:function(e){s(e,[i,"aborted",e])}};function u(){return i.aborted||a}function s(n,a,s){var c=s||("timeout"===n?"timeout":"aborted");u()||(h("aborting upload... "+c),i.aborted=1,t.stop(),i.error=c,e.error&&e.error.call(e.context,i,c,n),o.reject.apply(o,a),r&&re.event.trigger("ajaxError",[i,e,c]),l(c))}function c(){r&&re.event.trigger("ajaxComplete",[i,e]),r&&! --re.active&&re.event.trigger("ajaxStop")}function l(r){e.complete&&e.complete.call(e.context,i,r),c(),clearTimeout(n),setTimeout(function(){t.release(),i.responseXML=null},100)}function f(t){var n=t.status,u=t.errMsg;if(i.aborted)h("upload aborted");else if(i.status&&!(i.status>=200&&i.status<300||304===i.status)&&(n="error"),a=!0,"success"!==n)void 0===u&&(u=i.statusText),e.error&&e.error.call(e.context,i,n,u),o.reject(i,"error",u),r&&re.event.trigger("ajaxError",[i,e,u]),l(n);else{var s=function(t){var n;try{e.success.call(e.context,t,"success",i)}catch(e){n={error:e}}return o.resolve(i.responseText,"success",i),r&&re.event.trigger("ajaxSuccess",[i,e,t]),n}(t.data);if(l(n),s)throw s.error}}return o.abort=function(e){i.abort(e)},{xhr:i,deferred:o,start:function(){return(r=e.global)&&0===re.active++&&re.event.trigger("ajaxStart"),e.beforeSend&&!1===e.beforeSend.call(e.context,i,e)?(u()||(a=!0,o.reject(),r&&re.event.trigger("ajaxError",[i,e,"canceled"]),c()),!1):!i.aborted&&(r&&re.event.trigger("ajaxSend",[i,e]),!i.aborted)},done:u,abort:s,settle:f,fail:function(e){f({status:"error",errMsg:e})},startTimer:function(t){e.timeout&&(n=setTimeout(t,e.timeout))},stopTimer:function(){clearTimeout(n),n=void 0}}}var ae=e;function oe(e,t){var r=0;function n(e){var n=e.form,i=e.method,u=w(ae.extend(!0,{},ae.ajaxSettings,e.options),[ae.ajaxSettings,e.options]);u.context=u.context||u;var s=a(n,"ownerDocument"),l=ae(c(n,["body"])),f=function(e,t,r){var n,a;if(e.iframeTarget)(a=(n=ae(e.iframeTarget,r)).attr("name"))?t=a:(n.attr("name",t),n.each(function(){!function(e,t){try{e.contentWindow&&(e.contentWindow.name=t)}catch(e){}}(this,t)}));else{var o=r.createElement("iframe");o.setAttribute("name",t),o.setAttribute("src",e.iframeSrc),(n=ae(o)).css({position:"absolute",top:"-1000px",left:"-1000px"})}return{$io:n,id:t}}(u,"jqFormIO"+(new Date).getTime()+r++,s),d=f.$io,p=d[0],m=ne(u,function(e,t){return{stop:function(){try{t[0].contentWindow.document.execCommand&&t[0].contentWindow.document.execCommand("Stop")}catch(e){}t.attr("src",e.iframeSrc)},release:function(){e.iframeTarget?t.attr("src",e.iframeSrc):t.remove()}}}(u,d)),v=50;if(!m.start())return m.deferred;function g(){try{var e=Z(p).readyState;h("state = "+e),e&&"uninitialized"===e.toLowerCase()&&setTimeout(g,50)}catch(e){h("Server abort: ",e," (",e.name,")"),x(2),m.stopTimer()}}function y(){var r=function(e){var t={};return Q.each(V,function(r,n){t[n]=o(e,"hasAttribute",n)?o(e,"getAttribute",n):null}),t}(n);!function(e,t,r,n,a){var o="multipart/form-data";G(e,"target",t),!r||/post/i.test(r)?G(e,"method","POST"):_(r)&&!_(a.property(e,"method"))&&G(e,"method","GET"),G(e,"action",n.url),n.skipEncodingOverride||r&&!/post/i.test(r)||(G(e,"encoding",o),G(e,"enctype",o))}(n,f.id,i,u,t),m.startTimer(function(){x(1)});var a=[];try{!function(e,t,r,n,a){function o(r,n){var o=t.createElement("input");o.type="hidden",o.name=r,a.push(Q(o).val(n).appendTo(e)[0])}if(r)for(var i in r)if(B.call(r,i))if(Q.isPlainObject(r[i])&&B.call(r[i],"name")&&B.call(r[i],"value"))o(r[i].name,r[i].value);else{var u={};u[i]=r[i];for(var s=U(u,n),c=0;c=0?"&":"?")+t+e.url.slice(a.length),e.data=null}else e.data=t}(t,a.param(X(v),p),g),{form:c,$form:e,fields:v,controls:h,options:t,method:l,traditional:p}))},deliver:function(e){var t=e.$form,r=e.options,n=[];if(r.resetForm&&n.push(function(){t.resetForm()}),r.clearForm&&n.push(function(){t.clearForm(r.includeHidden)}),!r.dataType&&r.target){var o=l(r.success);n.push(function(e,t,n){var i=arguments,u=r.replaceTarget?"replaceWith":"html",s=a(r.target);"string"==typeof e?s[u](e):h("target: the response was parsed by jQuery, so it is not inserted"),s.length||f(o,this,i),s.each(function(){f(o,this,i)})})}else a.merge(n,l(r.success));if(r.success=function(e,a,o){for(var i=r.context||this,u=0,s=n.length;u0,u=/^[\t\n\f\r ]*multipart\/form-data[\t\n\f\r ]*$/i,s=u.test(r.attribute(n[0],"enctype"))||u.test(r.attribute(n[0],"encoding")),c=t.fileapi&&t.formdata;h("fileAPI :"+c);var l=(i||s)&&!c,f=(i||s)&&c?"formdata":"ajax";if(!1!==o.iframe&&(o.iframe||l)&&(f="iframe"),"iframe"!==f||o.iframe||y("iframe","choosing the iframe transport automatically without FormData is deprecated, set iframe: true"),"ajax"!==f&&"json"===o.requestFormat)throw new Error('jquery.form: requestFormat "json" cannot send files or use the iframe transport');return f}}}!function(e){var t={};t.fileapi=void 0!==e('').get(0).files,t.formdata=void 0!==window.FormData;var r=!!e.fn.prop;var n={attribute:M,property:function(e,t){var n=r?e[t]:void 0;return"string"==typeof n?n:M(e,t)}},a=R(t),u=ie(t,n,a),s={iframe:oe(r,n),formdata:z,ajax:W};e.fn.attr2=function(){if(y("attr2","attr2 is deprecated, use .prop() or .attr()"),!r)return this.attr.apply(this,arguments);var e=this.prop.apply(this,arguments);return e&&e.jquery||"string"==typeof e?e:this.attr.apply(this,arguments)},e.fn.ajaxSubmit=function(t,r,n,a){if(b(e.fn.jquery),!this.length)return h("ajaxSubmit: skipping submit process - no element selected"),this;if(!e.ajax)throw new Error("jquery.form: ajaxSubmit needs the full jQuery build; this jQuery has no $.ajax");var o=u.prepare(this,j(t,r,n,a));if(!o)return this;u.deliver(o);var i=s[u.chooseTransport(o)](o);this.removeData("jqxhr").data("jqxhr",i);for(var c=0;c=0)return r;return null}var g="jqFormSubmitter";function y(e,t,r){try{e[t]=r}catch(e){}}function b(e,t){var r=e[t],n=l(e,"elements");return n&&r&&n.namedItem(t)===r?void 0:r}function x(t,r,n,a){e.data(t,g,{el:r,x:n,y:a}),y(t,"clk",r),"image"===r.type&&(y(t,"clk_x",n),y(t,"clk_y",a)),setTimeout(function(){e.data(t,g,null),y(t,"clk",null),y(t,"clk_x",null),y(t,"clk_y",null)},100)}function j(t){var r=h(t.target,["button","input"]);if(r&&("submit"===r.type||"image"===r.type)){var n=r.form;if(n){var a="image"===r.type?function(t,r){if(void 0!==t.offsetX)return[t.offsetX,t.offsetY];if("function"==typeof e.fn.offset){var n=e(r).offset();return[t.pageX-n.left,t.pageY-n.top]}return[t.pageX-r.offsetLeft,t.pageY-r.offsetTop]}(t,r):[];x(n,r,a[0],a[1])}}}function T(t){if(!t)return null;var r=e.data(t,g);if(r)return r;var n=b(t,"clk");return n?{el:n,x:b(t,"clk_x"),y:b(t,"clk_y")}:null}function w(){if(e.fn.ajaxSubmit.debug){var t="[jquery.form] "+Array.prototype.join.call(arguments,"");r.console&&r.console.log?r.console.log(t):r.opera&&r.opera.postError&&r.opera.postError(t)}}var S={};function F(t,n){e.fn.ajaxSubmit.debug&&!S[t]&&(S[t]=!0,r.console&&"function"==typeof r.console.warn&&r.console.warn("[jquery.form] "+n+" (removed in 5.0)"))}function E(e){(function(e){var t=String(e).split("."),r=Number(t[0]);return r<3||3===r&&Number(t[1])<5})(e)&&F("jquery","support for jQuery "+e+" is deprecated, 5.0 needs jQuery 3.5 or later")}function D(e,t,r,n){if("string"!=typeof e&&!1!==e)return e;var a={url:e,data:t,dataType:r};return"function"==typeof n&&(a.success=n),a}function k(e,t,r,n){return"function"==typeof e?{success:e}:void 0===(e=D(e,t,r,n))?{}:!1===e.url||""===e.url?function(e){var t={};for(var r in e)"url"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t}(e):e}function q(e,t){for(var r=0;r"'),e(function(){e(n.s,n.c).ajaxForm(r)}),t):(w("terminating; zero elements found by selector"+(e.isReady?"":" (DOM not ready)")),t)}(this,t))}function H(t){return"string"==typeof t?($(t),this):(t!==P&&(I={},e(n).off("submit.form-plugin click.form-plugin")),this.off("submit.form-plugin click.form-plugin"))}function R(t,r){if(!m(t))return e(t).attr(r);var n=f(t,"getAttribute",r);return null===n?void 0:n}var z=/\r\n|\r|\n/g,U=/\r/g,V=/^(?:fieldset|object|output)$/;function W(t){if("select"===d(t))return function(e){var t=e.selectedIndex;if(t<0)return null;for(var r=[],n=e.options,a="select-one"===e.type,o=a?t+1:n.length,i=a?t:0;i=0,o=a?e.responseXML:e.responseText;return a&&"parsererror"===o.documentElement.nodeName&&fe.error&&fe.error("parsererror"),r&&r.dataFilter&&(o=r.dataFilter(o,t)),"string"==typeof o&&(("json"===t||!t)&&n.indexOf("json")>=0?o=JSON.parse(o):"script"===t&&fe.globalEval(o)),o}(t,c,n)}catch(e){u="parsererror",t.error=i=e||u}}catch(e){w("error caught: ",e),u="error",t.error=i=e}return{status:u,data:o,errMsg:i}}var ve=e;function he(e,t){var r,n,a,o=ve.Deferred(),i={aborted:0,responseText:null,responseXML:null,status:0,statusText:"n/a",getAllResponseHeaders:function(){},getResponseHeader:function(){},setRequestHeader:function(){},abort:function(e){s(e,[i,"aborted",e])}};function u(){return i.aborted||a}function s(n,a,s){var c=s||("timeout"===n?"timeout":"aborted");u()||(w("aborting upload... "+c),i.aborted=1,t.stop(),i.error=c,e.error&&e.error.call(e.context,i,c,n),o.reject.apply(o,a),r&&ve.event.trigger("ajaxError",[i,e,c]),l(c))}function c(){r&&ve.event.trigger("ajaxComplete",[i,e]),r&&! --ve.active&&ve.event.trigger("ajaxStop")}function l(r){e.complete&&e.complete.call(e.context,i,r),c(),clearTimeout(n),setTimeout(function(){t.release(),i.responseXML=null},100)}function f(t){var n=t.status,u=t.errMsg;if(i.aborted)w("upload aborted");else if(i.status&&!(i.status>=200&&i.status<300||304===i.status)&&("parsererror"===n&&(u=void 0),n="error"),a=!0,"success"!==n)void 0===u&&(u=i.statusText),e.error&&e.error.call(e.context,i,n,u),o.reject(i,n,u),r&&ve.event.trigger("ajaxError",[i,e,u]),l(n);else{var s=function(t){var n;try{e.success.call(e.context,t,"success",i)}catch(e){n={error:e}}return o.resolve(i.responseText,"success",i),r&&ve.event.trigger("ajaxSuccess",[i,e,t]),n}(t.data);if(l(n),s)throw s.error}}return o.abort=function(e){i.abort(e)},{xhr:i,deferred:o,start:function(){return(r=e.global)&&0===ve.active++&&ve.event.trigger("ajaxStart"),e.beforeSend&&!1===e.beforeSend.call(e.context,i,e)?(u()||(a=!0,o.reject(),r&&ve.event.trigger("ajaxError",[i,e,"canceled"]),c()),!1):!i.aborted&&(r&&ve.event.trigger("ajaxSend",[i,e]),!i.aborted)},done:u,abort:s,settle:f,fail:function(e){f({status:"error",errMsg:e})},startTimer:function(t){e.timeout&&(n=setTimeout(t,e.timeout))},stopTimer:function(){clearTimeout(n),n=void 0}}}var ge=e;function ye(e,t){var r=0;function n(e){var n=e.form,a=e.method,o=q(ge.extend(!0,{},ge.ajaxSettings,e.options),[ge.ajaxSettings,e.options]);o.context=o.context||o;var i=l(n,"ownerDocument"),u=ge(h(n,["body"])),s=function(e,t,r){var n,a;if(e.iframeTarget)(a=(n=A(e.iframeTarget,r)).attr("name"))?t=a:(n.attr("name",t),n.each(function(){!function(e,t){try{e.contentWindow&&(e.contentWindow.name=t)}catch(e){}}(this,t)}));else{var o=r.createElement("iframe");o.setAttribute("name",t),o.setAttribute("src",e.iframeSrc),(n=ge(o)).css({position:"absolute",top:"-1000px",left:"-1000px"})}return{$io:n,id:t}}(o,"jqFormIO"+(new Date).getTime()+r++,i),c=s.$io,d=c[0],p=he(o,function(e,t){return{stop:function(){try{t[0].contentWindow.document.execCommand&&t[0].contentWindow.document.execCommand("Stop")}catch(e){}t.attr("src",e.iframeSrc)},release:function(){e.iframeTarget?t.attr("src",e.iframeSrc):t.remove()}}}(o,c)),m=50;if(!p.start())return p.deferred;function v(){try{var e=de(d).readyState;w("state = "+e),e&&"uninitialized"===e.toLowerCase()&&setTimeout(v,50)}catch(e){w("Server abort: ",e," (",e.name,")"),b(2),p.stopTimer()}}function g(){var r=function(e){var t={};return ae.each(oe,function(r,n){t[n]=f(e,"hasAttribute",n)?f(e,"getAttribute",n):null}),t}(n);!function(e,t,r,n,a){var o="multipart/form-data";le(e,"target",t),!r||/post/i.test(r)?le(e,"method","POST"):ue(r)&&!ue(a.property(e,"method"))&&le(e,"method","GET"),le(e,"action",n.url),n.skipEncodingOverride||r&&!/post/i.test(r)||(le(e,"encoding",o),le(e,"enctype",o))}(n,s.id,a,o,t),p.startTimer(function(){b(1)});var l=[];try{!function(e,t,r,n,a){function o(r,n){var o=t.createElement("input");o.type="hidden",o.name=r,a.push(ae(o).val(n).appendTo(e)[0])}if(r)for(var i in r)if(ie.call(r,i))if(ae.isPlainObject(r[i])&&ie.call(r[i],"name")&&ie.call(r[i],"value"))o(K(r[i].name),K(r[i].value));else{var u={};u[i]=r[i];for(var s=te(u,n),c=0;c=0?"&":"?")+t+e.url.slice(a.length),e.data=null}else e.data=t}(t,J(y,h),x),{form:f,$form:e,fields:y,controls:b,options:t,method:d,traditional:h}))},deliver:function(e){var t=e.$form,r=e.options,n=[];if(r.resetForm&&n.push(function(){t.resetForm()}),r.clearForm&&n.push(function(){t.clearForm(r.includeHidden)}),!r.dataType&&r.target){var a=d(r.success);n.push(function(e,t,n){var o=arguments,i=r.replaceTarget?"replaceWith":"html",u=A(r.target);"string"==typeof e?u[i](e):w("target: the response was parsed by jQuery, so it is not inserted"),u.length||p(a,this,o),u.each(function(){p(a,this,o)})})}else u.merge(n,d(r.success));if(r.success=function(e,a,o){for(var i=r.context||this,u=0,s=n.length;u0,i=/^[\t\n\f\r ]*multipart\/form-data[\t\n\f\r ]*$/i,s=i.test(o.attribute(r[0],"enctype"))||i.test(o.attribute(r[0],"encoding")),c=t.fileapi&&t.formdata;w("fileAPI :"+c);var l=(a||s)&&!c,f=(a||s)&&c?"formdata":"ajax";if(!1!==n.iframe&&(n.iframe||l)&&(f="iframe"),"iframe"!==f||n.iframe||F("iframe","choosing the iframe transport automatically without FormData is deprecated, set iframe: true"),"ajax"!==f&&"json"===n.requestFormat)throw new Error('jquery.form: requestFormat "json" cannot send files or use the iframe transport');return f}}}!function(e){var t={};t.fileapi=void 0!==e('').get(0).files,t.formdata=void 0!==r.FormData;var n=!!e.fn.prop;var o={attribute:R,property:function(e,t){var r=n?e[t]:void 0;return"string"==typeof r?r:R(e,t)}},i=Z(t),u=be(t,o,i),s={iframe:ye(n,o),formdata:re,ajax:ne};e.fn.attr2=function(){if(F("attr2","attr2 is deprecated, use .prop() or .attr()"),!n)return this.attr.apply(this,arguments);var e=this.prop.apply(this,arguments);return e&&e.jquery||"string"==typeof e?e:this.attr.apply(this,arguments)},e.fn.ajaxSubmit=function(t,r,n,a){if(E(e.fn.jquery),!this.length)return w("ajaxSubmit: skipping submit process - no element selected"),this;if(!e.ajax)throw new Error("jquery.form: ajaxSubmit needs the full jQuery build; this jQuery has no $.ajax");var o=u.prepare(this,k(t,r,n,a));if(!o)return this;u.deliver(o);var i=s[u.chooseTransport(o)](o);this.removeData("jqxhr").data("jqxhr",i);for(var c=0;c= 0) {\n return node;\n }\n }\n\n return null;\n}\n","import { closestByTag, formMember } from \"./form-members.js\";\nimport jQuery from \"jquery\";\n\n// The submitter: the button that submitted a form, captured from ajaxForm's clicks. It is kept in\n// a private store and cleared shortly after the click. The form's clk, clk_x and clk_y properties\n// are still written for pages that read them, and read when the store has none.\n\nvar storeKey = \"jqFormSubmitter\";\n\n// Writes a property on the form; a control with that name makes it read-only.\nfunction setExpando(form, name, value) {\n try {\n form[name] = value;\n } catch (ignore) {\n // the control keeps the name; the store has the submitter\n }\n}\n\n// A property the page set on the form, never a control of the form with that name.\nfunction expando(form, name) {\n var value = form[name];\n var els = formMember(form, \"elements\");\n\n return els && value && els.namedItem(name) === value ? undefined : value;\n}\n\n// Records a submitter for a form until the click window ends.\nfunction record(form, el, x, y) {\n jQuery.data(form, storeKey, { el: el, x: x, y: y });\n setExpando(form, \"clk\", el);\n\n if (el.type === \"image\") {\n setExpando(form, \"clk_x\", x);\n setExpando(form, \"clk_y\", y);\n }\n\n // clear form vars\n setTimeout(function () {\n jQuery.data(form, storeKey, null);\n setExpando(form, \"clk\", null);\n setExpando(form, \"clk_x\", null);\n setExpando(form, \"clk_y\", null);\n }, 100);\n}\n\n// The clicked point of an image button, relative to the image.\nfunction imagePoint(e, target) {\n if (typeof e.offsetX !== \"undefined\") {\n return [e.offsetX, e.offsetY];\n }\n\n if (typeof jQuery.fn.offset === \"function\") {\n var offset = jQuery(target).offset();\n\n return [e.pageX - offset.left, e.pageY - offset.top];\n }\n\n return [e.pageX - target.offsetLeft, e.pageY - target.offsetTop];\n}\n\n/**\n * Records the submit or image button a click event reached, for the form it belongs to.\n */\nexport function captureSubmitter(e) {\n // the clicked control, or the button around the clicked content (ex: a span within a button)\n var target = closestByTag(e.target, [\"button\", \"input\"]);\n\n // the type property, unlike the attribute, is \"submit\" for a button without a type (#588)\n if (!target || (target.type !== \"submit\" && target.type !== \"image\")) {\n return;\n }\n\n var form = target.form;\n\n if (!form) {\n // a submit control that belongs to no form\n return;\n }\n\n var point = target.type === \"image\" ? imagePoint(e, target) : [];\n\n record(form, target, point[0], point[1]);\n}\n\n/**\n * Records the submitter a submit event names (SubmitEvent.submitter), when no click was captured.\n * An image submitter gets the point 0,0, as native submission sends it without a click.\n */\nexport function captureEventSubmitter(e, form) {\n var el = e.originalEvent && e.originalEvent.submitter;\n\n if (el && !submitterOf(form)) {\n record(form, el, 0, 0);\n }\n}\n\n/**\n * The form's submitter as { el, x, y } (x and y for an image button), or null.\n */\nexport function submitterOf(form) {\n if (!form) {\n return null;\n }\n\n var stored = jQuery.data(form, storeKey);\n\n if (stored) {\n return stored;\n }\n\n var el = expando(form, \"clk\");\n\n return el ? { el: el, x: expando(form, \"clk_x\"), y: expando(form, \"clk_y\") } : null;\n}\n\n/**\n * The submitter's fields for a post that adds them itself (the iframe upload), as name → value.\n */\nexport function submitterFields(form) {\n var fields = {};\n var sub = submitterOf(form);\n var el = sub && sub.el;\n\n if (el && el.name && !el.disabled) {\n fields[el.name] = el.value;\n if (el.type === \"image\") {\n fields[el.name + \".x\"] = sub.x;\n fields[el.name + \".y\"] = sub.y;\n }\n }\n\n return fields;\n}\n\n/**\n * The form's submitter element, or null.\n */\nexport function submitterElement(form) {\n var sub = submitterOf(form);\n\n return sub ? sub.el : null;\n}\n","import jQuery from \"jquery\";\n\n// Debug logging, switched on by $.fn.ajaxSubmit.debug. The flag is read on every call, so it can\n// be turned on after the plugin loads.\nexport function log() {\n if (!jQuery.fn.ajaxSubmit.debug) {\n return;\n }\n\n var msg = \"[jquery.form] \" + Array.prototype.join.call(arguments, \"\");\n\n if (window.console && window.console.log) {\n window.console.log(msg);\n } else if (window.opera && window.opera.postError) {\n window.opera.postError(msg);\n }\n}\n\nvar warned = {};\n\n/**\n * A deprecation warning: console.warn, only while debug is on, once per id per page. The message\n * names the replacement; the warning adds that the feature is removed in 5.0.\n */\nexport function deprecate(id, message) {\n if (!jQuery.fn.ajaxSubmit.debug || warned[id]) {\n return;\n }\n\n warned[id] = true;\n\n if (window.console && typeof window.console.warn === \"function\") {\n window.console.warn(\"[jquery.form] \" + message + \" (removed in 5.0)\");\n }\n}\n\n// Forgets which deprecations have warned (for tests).\nexport function resetDeprecations() {\n warned = {};\n}\n\n// True for a jQuery version string older than 3.5.\nexport function beforeJQuery35(version) {\n var parts = String(version).split(\".\");\n var major = Number(parts[0]);\n\n return major < 3 || (major === 3 && Number(parts[1]) < 5);\n}\n\n// 5.0 needs jQuery 3.5 or later: warned on the first ajaxSubmit or ajaxForm, given jQuery's version.\nexport function deprecateOldJQuery(version) {\n if (beforeJQuery35(version)) {\n deprecate(\n \"jquery\",\n \"support for jQuery \" + version + \" is deprecated, 5.0 needs jQuery 3.5 or later\"\n );\n }\n}\n","// The arguments ajaxSubmit and ajaxForm accept in place of an options object.\n\n/**\n * Turns the (url, data, dataType, success) shorthand into options. A url of false is kept as\n * the url; anything else is returned as given.\n */\nexport function shorthandOptions(options, data, dataType, onSuccess) {\n if (typeof options !== \"string\" && options !== false) {\n return options;\n }\n\n var result = { url: options, data: data, dataType: dataType };\n\n if (typeof onSuccess === \"function\") {\n result.success = onSuccess;\n }\n\n return result;\n}\n\n// A copy of options without its url, so the form action is used.\nfunction withoutUrl(options) {\n var result = {};\n\n for (var key in options) {\n if (key !== \"url\" && Object.prototype.hasOwnProperty.call(options, key)) {\n result[key] = options[key];\n }\n }\n\n return result;\n}\n\n/**\n * The options ajaxSubmit starts from: a function is the success callback, the shorthand is\n * expanded, and no options at all is an empty object. A url of false or \"\" means the form action.\n */\nexport function submitOptions(options, data, dataType, onSuccess) {\n if (typeof options === \"function\") {\n return { success: options };\n }\n\n options = shorthandOptions(options, data, dataType, onSuccess);\n\n if (typeof options === \"undefined\") {\n return {};\n }\n\n return options.url === false || options.url === \"\" ? withoutUrl(options) : options;\n}\n\n/**\n * jQuery treats `context` as a flat option: after a deep merge, the settings get back the\n * caller's own object from the last source that has one, so `this` in callbacks is that object.\n */\nexport function keepContext(settings, sources) {\n for (var i = 0; i < sources.length; i++) {\n if (sources[i].context !== undefined) {\n settings.context = sources[i].context;\n }\n }\n\n return settings;\n}\n","import { assertRealParent, closestByTag, formMember, isElement } from \"./form-members.js\";\nimport { captureEventSubmitter, captureSubmitter } from \"./submitter.js\";\nimport { deprecate, deprecateOldJQuery, log } from \"./diagnostics.js\";\nimport jQuery from \"jquery\";\nimport { shorthandOptions } from \"./options.js\";\n\n// ajaxForm binding: the submit and click handlers that send a form through ajaxSubmit. The\n// handlers look up $.fn.ajaxSubmit when they run, so a replacement installed later is used.\n\n// Sends the submit event's form with ajaxSubmit, unless an earlier handler cancelled it.\nfunction submitWith(e, options) {\n if (!e.isDefaultPrevented()) {\n // if event has been canceled, don't proceed\n e.preventDefault();\n // the form is found through the real tree: a control named nodeType misleads jQuery's closest\n var form = closestByTag(e.target, [\"form\"]);\n\n // a button outside the form (form attribute), or requestSubmit(button), sends no click here\n captureEventSubmitter(e, form);\n jQuery(form).ajaxSubmit(options); // #365\n }\n}\n\nfunction doAjaxSubmit(e) {\n submitWith(e, e.data);\n}\n\nfunction captureSubmittingElement(e) {\n /* jshint validthis:true */\n assertRealParent(this);\n captureSubmitter(e);\n}\n\n// An empty selection: queued until the DOM is ready (old jQuery keeps the selector), or dropped.\nfunction bindLater($sel, options) {\n var o = { s: $sel.selector, c: $sel.context };\n\n if (!jQuery.isReady && o.s) {\n log(\"DOM not ready, queuing ajaxForm\");\n deprecate(\n \"queue\",\n \"queuing ajaxForm until the DOM is ready is deprecated, call ajaxForm inside $(fn) \" +\n 'or use delegation: \"\"'\n );\n jQuery(function () {\n jQuery(o.s, o.c).ajaxForm(options);\n });\n\n return $sel;\n }\n\n // is your DOM ready? http://docs.jquery.com/Tutorials:Introducing_$(document).ready()\n log(\"terminating; zero elements found by selector\" + (jQuery.isReady ? \"\" : \" (DOM not ready)\"));\n\n return $sel;\n}\n\n// delegation: true on jQuery 3 and later, where the selection has no selector: always warned,\n// debug or not, once per ajaxForm call.\nfunction warnUnscoped() {\n var console = window.console || {};\n\n if (typeof console.warn === \"function\") {\n console.warn(\n \"[jquery.form] delegation: true binds every form on the page on jQuery 3 and later; \" +\n 'pass a selector instead, e.g. delegation: \"form.ajax\"'\n );\n }\n}\n\nfunction bindDelegated($sel, options) {\n if ($sel.selector === undefined) {\n warnUnscoped();\n }\n\n jQuery(document)\n .off(\"submit.form-plugin\", $sel.selector, doAjaxSubmit)\n .off(\"click.form-plugin\", $sel.selector, captureSubmittingElement)\n .on(\"submit.form-plugin\", $sel.selector, options, doAjaxSubmit)\n .on(\"click.form-plugin\", $sel.selector, options, captureSubmittingElement);\n\n return $sel;\n}\n\n// The element itself or its nearest ancestor that matches the selector. The walk never reads a\n// parentNode a control can hide (jQuery's delegated walk does, and cycles on such a form).\nfunction closestMatch(el, selector) {\n if (!isElement(el)) {\n return null;\n }\n\n if (window.Element && Element.prototype.closest) {\n return Element.prototype.closest.call(el, selector);\n }\n\n for (var node = el; node && isElement(node); node = formMember(node, \"parentNode\")) {\n if (jQuery(node).is(selector)) {\n return node;\n }\n }\n\n return null;\n}\n\n// The document handlers bound for each delegation selector, keyed by \"s\" + selector.\nvar delegated = {};\n\nfunction unbindSelector(selector) {\n var handlers = delegated[\"s\" + selector];\n\n if (handlers) {\n jQuery(document)\n .off(\"submit.form-plugin\", handlers.submit)\n .off(\"click.form-plugin\", handlers.click);\n delete delegated[\"s\" + selector];\n }\n}\n\n// delegation: \"\": one handler pair on the document, scoped to the selector.\nfunction bindSelector($sel, selector, options) {\n if (!selector) {\n throw new Error(\"jquery.form: delegation needs a selector, or true\");\n }\n\n var handlers = {\n submit: function (e) {\n if (closestMatch(e.target, selector)) {\n submitWith(e, options);\n }\n },\n click: function (e) {\n if (closestMatch(e.target, selector)) {\n captureSubmitter(e);\n }\n },\n };\n\n unbindSelector(selector);\n delegated[\"s\" + selector] = handlers;\n jQuery(document)\n .on(\"submit.form-plugin\", handlers.submit)\n .on(\"click.form-plugin\", handlers.click);\n\n return $sel;\n}\n\n// Passed by ajaxForm's own rebind: unbind the selection only, never the document handlers.\nvar selectionOnly = {};\n\n/**\n * ajaxForm() binds the selected forms so a submit is sent with ajaxSubmit, with the clicked\n * submit button (and image coordinates) included. The options work as for ajaxSubmit.\n */\nexport function ajaxForm(options, data, dataType, onSuccess) {\n deprecateOldJQuery(jQuery.fn.jquery);\n options = shorthandOptions(options, data, dataType, onSuccess) || {};\n\n if (typeof options.delegation === \"string\") {\n return bindSelector(this, options.delegation, options);\n }\n\n options.delegation = options.delegation && typeof jQuery.fn.on === \"function\";\n\n if (!options.delegation && this.length === 0) {\n return bindLater(this, options);\n }\n\n if (options.delegation) {\n return bindDelegated(this, options);\n }\n\n if (options.beforeFormUnbind) {\n options.beforeFormUnbind(this, options);\n }\n\n return this.ajaxFormUnbind(selectionOnly)\n .on(\"submit.form-plugin\", options, doAjaxSubmit)\n .on(\"click.form-plugin\", options, captureSubmittingElement);\n}\n\n/**\n * ajaxFormUnbind() removes the handlers ajaxForm bound on the selection and every delegated\n * binding on the document. ajaxFormUnbind(selector) removes only that delegation selector.\n */\nexport function ajaxFormUnbind(selector) {\n if (typeof selector === \"string\") {\n unbindSelector(selector);\n\n return this;\n }\n\n if (selector !== selectionOnly) {\n delegated = {};\n jQuery(document).off(\"submit.form-plugin click.form-plugin\");\n }\n\n return this.off(\"submit.form-plugin click.form-plugin\");\n}\n","import { callFormMethod, isElement } from \"./form-members.js\";\nimport jQuery from \"jquery\";\n\n/**\n * An attribute of a form, or undefined when it is absent, as jQuery's attr returns it. The\n * subject may also be the document or a plain object, read through jQuery.\n */\nexport function formAttribute(form, name) {\n if (!isElement(form)) {\n return jQuery(form).attr(name);\n }\n\n var value = callFormMethod(form, \"getAttribute\", name);\n\n return value === null ? undefined : value;\n}\n","import { callFormMethod, formMember, isElement, tagName } from \"./form-members.js\";\nimport { formAttribute } from \"./form-attributes.js\";\nimport jQuery from \"jquery\";\nimport { submitterOf } from \"./submitter.js\";\n\n// Successful controls: which controls of a form are sent, and as which name/value fields\n// (https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#constructing-the-form-data-set).\n\n// Line breaks, sent as CRLF\nvar rLineBreak = /\\r\\n|\\r|\\n/g;\nvar rCR = /\\r/g;\n\n// Listed form elements that are never submitted.\nvar rUnsubmittable = /^(?:fieldset|object|output)$/;\n\n/**\n * Whether a control or option is disabled, also through a disabled fieldset or optgroup. Without\n * selector matching, only its own disabled property is read.\n */\nfunction isDisabled(el) {\n return typeof el.matches === \"function\" ? el.matches(\":disabled\") : !!el.disabled;\n}\n\n/**\n * The successful-control rule: whether a control is sent. `submitter` is the button that\n * submitted the control's form; other submit and image buttons of a form are not sent.\n */\nexport function isSuccessful(el, submitter) {\n var t = el.type;\n\n if (!el.name || isDisabled(el) || t === \"reset\" || t === \"button\") {\n return false;\n }\n\n if (t === \"checkbox\" || t === \"radio\") {\n return !!el.checked;\n }\n\n if (t === \"submit\" || t === \"image\") {\n return !el.form || submitter === el;\n }\n\n return tagName(el) !== \"select\" || el.selectedIndex !== -1;\n}\n\n// The value of a select: the selected option's value for one, a list for several.\nfunction selectValue(el) {\n var index = el.selectedIndex;\n\n if (index < 0) {\n return null;\n }\n\n var a = [],\n ops = el.options;\n var one = el.type === \"select-one\";\n var max = one ? index + 1 : ops.length;\n\n for (var i = one ? index : 0; i < max; i++) {\n var op = ops[i];\n\n if (op.selected && !isDisabled(op)) {\n var v = op.value;\n\n if (!v) {\n // extra pain for IE...\n v =\n op.attributes && op.attributes.value && !op.attributes.value.specified\n ? op.text\n : op.value;\n }\n\n if (one) {\n return v;\n }\n\n a.push(v);\n }\n }\n\n return a;\n}\n\n/**\n * The value of a control, whether or not it is successful: a list for a multiple select, null\n * for a select with nothing selected, otherwise a string with CRLF line breaks (a lone CR or LF\n * included).\n */\nexport function valueOf(el) {\n if (tagName(el) === \"select\") {\n return selectValue(el);\n }\n\n var v = jQuery(el).val();\n var raw = el.value;\n\n // jQuery before 4.0 drops carriage returns from .val(); read them from the value itself\n if (typeof raw === \"string\" && raw.replace(rCR, \"\") === v) {\n v = raw;\n }\n\n return v.replace(rLineBreak, \"\\r\\n\");\n}\n\n/**\n * The fields as a urlencoded body sends them: a selected file as its name.\n */\nexport function urlencodedFields(fields) {\n return jQuery.map(fields, function (field) {\n return field.type === \"file\" && typeof field.value !== \"string\"\n ? { name: field.name, value: field.value.name }\n : field;\n });\n}\n\n/**\n * The serialization steps. `feature` holds what the entry detected at load (fileapi).\n */\nexport function createSuccessfulControls(feature) {\n var $ = jQuery;\n\n // #386; inputs that name the form in their form attribute, other than the candidates found.\n // A form only gets the ones it owns.\n function outsideControls(formId, els, owner) {\n // hat tip @thet; the id is compared, never built into a selector\n return $(\":input[form]\")\n .filter(function () {\n return (\n this.getAttribute(\"form\") === formId &&\n (!owner || this.form === owner) &&\n $.inArray(this, els) < 0\n );\n })\n .get();\n }\n\n // A descendant of a form is a candidate unless it is a control another form owns.\n function ownedBy(els, owner) {\n return $.grep(els, function (el) {\n return typeof el.form === \"undefined\" || el.form === owner;\n });\n }\n\n /**\n * The candidate controls of a form, in order: its elements, or every descendant it owns in\n * semantic mode, then the outside controls it owns that name it.\n */\n function controlsOf(form, semantic) {\n var formId = formAttribute(form, \"id\");\n var els = formMember(form, \"elements\");\n\n if (semantic || typeof els === \"undefined\") {\n // the document is not an element; it has its own getElementsByTagName\n els = isElement(form)\n ? callFormMethod(form, \"getElementsByTagName\", \"*\")\n : form.getElementsByTagName(\"*\");\n }\n\n els = $.makeArray(els);\n\n // the subject may also be a fieldset, the document or another container\n var owner = tagName(form) === \"form\" ? form : null;\n\n if (semantic && owner) {\n els = ownedBy(els, owner);\n }\n\n // FinesseRus: in non-IE browsers outside fields are already included in form.elements.\n if (formId && (semantic || /(Edge|Trident)\\//.test(navigator.userAgent))) {\n els = els.concat(outsideControls(formId, els, owner));\n }\n\n return els;\n }\n\n // The fields of a control's value, or null when the control is not sent.\n function fieldsOf(el) {\n var n = el.name;\n // read at call time, so a page that replaces $.fieldValue changes what is sent\n var v = $.fieldValue(el, true);\n\n if (v && v.constructor === Array) {\n return $.map(v, function (value) {\n return { name: n, value: value };\n });\n }\n\n if (feature.fileapi && el.type === \"file\") {\n var files = el.files;\n\n // #180: an empty field when no file is selected\n return files.length\n ? $.map(files, function (file) {\n return { name: n, value: file, type: el.type };\n })\n : [{ name: n, value: \"\", type: el.type }];\n }\n\n if (v === null || typeof v === \"undefined\") {\n return null;\n }\n\n return [{ name: n, value: v, type: el.type, required: el.required }];\n }\n\n // The clicked image's value and coordinates.\n function imageFields(sub, input, type) {\n var n = input.name;\n var value = { name: n, value: $(input).val() };\n\n if (type) {\n value.type = type;\n }\n\n return [value, { name: n + \".x\", value: sub.x }, { name: n + \".y\", value: sub.y }];\n }\n\n // Adds one candidate control's fields, and the control when it has a value to send.\n function addCandidate(collected, form, el, semantic) {\n if (!el.name || isDisabled(el) || rUnsubmittable.test(tagName(el))) {\n return;\n }\n\n var sub = semantic && el.type === \"image\" && submitterOf(form);\n\n if (sub) {\n // handle image inputs on the fly when semantic == true\n if (sub.el === el) {\n collected.fields.push.apply(collected.fields, imageFields(sub, el, el.type));\n }\n\n return;\n }\n\n var own = fieldsOf(el);\n\n if (own) {\n collected.controls.push(el);\n collected.fields.push.apply(collected.fields, own);\n }\n }\n\n // input type=='image' are not found in elements array! handle it here\n function addClickedImage(collected, form) {\n var sub = submitterOf(form);\n var input = sub && $(sub.el)[0];\n\n if (input && input.name && !isDisabled(input) && input.type === \"image\") {\n collected.fields.push.apply(collected.fields, imageFields(sub, input));\n }\n }\n\n /**\n * The fields of a form, as formToArray returns them, and the controls they came from.\n */\n function collect(form, semantic, filtering) {\n var collected = { fields: [], controls: [] };\n\n if (!form) {\n return collected;\n }\n\n var els = controlsOf(form, semantic);\n\n if (typeof filtering === \"function\") {\n els = $.map(els, filtering);\n }\n\n for (var i = 0; i < els.length; i++) {\n addCandidate(collected, form, els[i], semantic);\n }\n\n if (!semantic) {\n addClickedImage(collected, form);\n }\n\n return collected;\n }\n\n return {\n controlsOf: controlsOf,\n fieldsOf: fieldsOf,\n collect: collect,\n };\n}\n","import jQuery from \"jquery\";\nimport { keepContext } from \"./options.js\";\n\n// The XMLHttpRequest transports: $.ajax with the encoded fields, or FormData for file uploads.\nvar $ = jQuery;\n\n// utility fn for deep serialization: [name, value] pairs, as $.param encodes them\nexport function deepSerialize(extraData, traditional) {\n var param = $.param(extraData, traditional);\n var serialized = param ? param.split(\"&\") : [];\n var len = serialized.length;\n var result = [];\n var i, part;\n\n for (i = 0; i < len; i++) {\n // #252; undo param space replacement\n serialized[i] = serialized[i].replace(/\\+/g, \" \");\n part = serialized[i].split(\"=\");\n // #278; use array instead of object storage, favoring array serializations\n result.push([decodeURIComponent(part[0]), decodeURIComponent(part[1])]);\n }\n\n return result;\n}\n\n/**\n * Posts the fields and extraData as FormData, for files with the File API.\n * XMLHttpRequest Level 2 file uploads (big hat tip to francois2metz)\n */\nexport function sendFormData(submission) {\n var options = submission.options;\n var a = submission.fields;\n\n var formdata = new FormData();\n\n for (var i = 0; i < a.length; i++) {\n formdata.append(a[i].name, a[i].value);\n }\n\n if (options.extraData) {\n var serializedData = deepSerialize(options.extraData, submission.traditional);\n\n for (i = 0; i < serializedData.length; i++) {\n formdata.append(serializedData[i][0], serializedData[i][1]);\n }\n }\n\n options.data = null;\n\n var s = $.extend(true, {}, $.ajaxSettings, options, {\n contentType: false,\n processData: false,\n cache: false,\n type: submission.method || \"POST\",\n });\n\n keepContext(s, [$.ajaxSettings, options]);\n\n if (options.uploadProgress) {\n // workaround because jqXHR does not expose upload property: wraps the xhr factory, the\n // caller's or jQuery's\n var createXhr = s.xhr;\n\n s.xhr = function () {\n var xhr = createXhr.call(this);\n\n if (xhr.upload) {\n xhr.upload.addEventListener(\n \"progress\",\n function (event) {\n var percent = 0;\n // event.position is the deprecated name, read only when loaded is missing\n var position = event.loaded !== undefined ? event.loaded : event.position;\n var total = event.total;\n\n if (event.lengthComputable) {\n percent = Math.ceil((position / total) * 100);\n }\n\n options.uploadProgress(event, position, total, percent);\n },\n false\n );\n }\n\n return xhr;\n };\n }\n\n s.data = null;\n\n var beforeSend = s.beforeSend;\n\n s.beforeSend = function (xhr, o) {\n // Send FormData() provided by user\n if (options.formData) {\n o.data = options.formData;\n } else {\n o.data = formdata;\n }\n\n // a veto (false) cancels the upload, as on the other transports\n return beforeSend ? beforeSend.call(this, xhr, o) : undefined;\n };\n\n return $.ajax(s);\n}\n\n/**\n * Sends the encoded fields with $.ajax.\n */\nexport function sendAjax(submission) {\n return $.ajax(submission.options);\n}\n","import { callFormMethod } from \"./form-members.js\";\nimport { deepSerialize } from \"./xhr-transport.js\";\nimport jQuery from \"jquery\";\nimport { submitterFields } from \"./submitter.js\";\n\n// The iframe form post: the extra fields (submitter, CSRF, data), the form attributes set while\n// posting and restored after, and the native submit.\nvar $ = jQuery;\n\n// The form attributes an iframe upload changes while it posts.\nvar uploadAttributes = [\"action\", \"target\", \"method\", \"enctype\", \"encoding\"];\n\n// Called through the prototype: an extraData key or a form field may be named hasOwnProperty.\nvar hasOwn = Object.prototype.hasOwnProperty;\n\nfunction isGet(method) {\n return /^get$/i.test(method);\n}\n\n// Resolves both URLs through anchors, as jQuery does for crossDomain, so IE's anchor quirks\n// apply to both sides of the comparison.\nfunction isSameOrigin(url) {\n var origin = document.createElement(\"a\");\n var target = document.createElement(\"a\");\n\n origin.href = window.location.href;\n target.href = url;\n // IE fills in the host of a relative URL only once the resolved href is assigned back\n target.href = target.href; // eslint-disable-line no-self-assign\n\n return origin.protocol + \"//\" + origin.host === target.protocol + \"//\" + target.host;\n}\n\n/** Adds the clicked submitter (and an image's coordinates) to s.extraData. */\nexport function addSubmitterFields(s, form) {\n // add submitting element to data if we know it\n var fields = submitterFields(form);\n\n for (var n in fields) {\n s.extraData = s.extraData || {};\n s.extraData[n] = fields[n];\n }\n}\n\n/** Adds the page's CSRF token to s.extraData when the form is posted to the page's origin. */\nexport function addCsrfField(s, form, method, forms) {\n // Rails CSRF hack (thanks to Yvan Barthelemy); like jquery-ujs, only for the page's origin and\n // only when the form is posted, since a get form would put the token in the url\n var csrf_token = $(\"meta[name=csrf-token]\").attr(\"content\");\n var csrf_param = $(\"meta[name=csrf-param]\").attr(\"content\");\n var posts =\n !isGet(method) &&\n (!method || /post/i.test(method) || /post/i.test(forms.property(form, \"method\")));\n\n if (csrf_param && csrf_token && posts && isSameOrigin(s.url)) {\n s.extraData = s.extraData || {};\n s.extraData[csrf_param] = csrf_token;\n }\n}\n\nfunction setFormAttribute(form, name, value) {\n callFormMethod(form, \"setAttribute\", name, value);\n}\n\n/** The raw attributes the upload changes, null when absent, to put back exactly (#380). */\nexport function saveAttributes(form) {\n var saved = {};\n\n $.each(uploadAttributes, function (i, name) {\n saved[name] = callFormMethod(form, \"hasAttribute\", name)\n ? callFormMethod(form, \"getAttribute\", name)\n : null;\n });\n\n return saved;\n}\n\n/** Puts back the attributes saveAttributes recorded, removing those that were absent. */\nexport function restoreAttributes(form, saved) {\n $.each(uploadAttributes, function (i, name) {\n if (saved[name] === null) {\n callFormMethod(form, \"removeAttribute\", name);\n } else {\n setFormAttribute(form, name, saved[name]);\n }\n });\n}\n\n/** Points the form at the frame `target` with the upload's url, method and encoding. */\nexport function setUploadAttributes(form, target, method, s, forms) {\n var mp = \"multipart/form-data\";\n\n // update form attrs in IE friendly way\n setFormAttribute(form, \"target\", target);\n if (!method || /post/i.test(method)) {\n setFormAttribute(form, \"method\", \"POST\");\n } else if (isGet(method) && !isGet(forms.property(form, \"method\"))) {\n // a form posts natively only with GET or POST; other verbs keep the form's own method\n setFormAttribute(form, \"method\", \"GET\");\n }\n setFormAttribute(form, \"action\", s.url);\n\n // ie borks in some cases when setting encoding\n if (!s.skipEncodingOverride && (!method || /post/i.test(method))) {\n setFormAttribute(form, \"encoding\", mp);\n setFormAttribute(form, \"enctype\", mp);\n }\n}\n\n/** Appends a hidden input per extraData field to the form; each input is pushed onto `added`. */\nexport function addExtraInputs(form, ownerDocument, extraData, traditional, added) {\n // Builds the input with DOM properties: a name is never parsed as HTML.\n function addHiddenInput(name, value) {\n var input = ownerDocument.createElement(\"input\");\n\n input.type = \"hidden\";\n input.name = name;\n added.push($(input).val(value).appendTo(form)[0]);\n }\n\n if (extraData) {\n for (var n in extraData) {\n if (hasOwn.call(extraData, n)) {\n // if using the $.param format that allows for multiple values with the same name\n if (\n $.isPlainObject(extraData[n]) &&\n hasOwn.call(extraData[n], \"name\") &&\n hasOwn.call(extraData[n], \"value\")\n ) {\n addHiddenInput(extraData[n].name, extraData[n].value);\n } else {\n // arrays and objects become one field per value, as $.param sends them (#597)\n var single = {};\n\n single[n] = extraData[n];\n var fields = deepSerialize(single, traditional);\n\n for (var f = 0; f < fields.length; f++) {\n addHiddenInput(fields[f][0], fields[f][1]);\n }\n }\n }\n }\n }\n}\n\n/** Submits the form natively, even when a control named submit hides the method. */\nexport function submitForm(form) {\n try {\n form.submit();\n } catch (err) {\n // just in case form has element with name/id of 'submit'\n callFormMethod(form, \"submit\");\n }\n}\n","import jQuery from \"jquery\";\nimport { log } from \"./diagnostics.js\";\n\n// The iframe response reader: turns the frame's document into the mock xhr's text, XML, status\n// and dataType, then parses it as $.ajax would (dataFilter, JSON, script).\nvar $ = jQuery;\n\n/** The frame's document, or null when the browser denies access to it. */\nexport function getDoc(frame) {\n /* it looks like contentWindow or contentDocument do not\n * carry the protocol property in ie8, when running under ssl\n * frame.document is the only valid response document, since\n * the protocol is know but not on the other two objects. strange?\n * \"Same origin policy\" http://en.wikipedia.org/wiki/Same_origin_policy\n */\n\n var doc = null;\n\n // IE8 cascading access check\n try {\n if (frame.contentWindow) {\n doc = frame.contentWindow.document;\n }\n } catch (err) {\n // IE8 access denied under ssl & missing protocol\n log(\"cannot get iframe.contentWindow document: \" + err);\n }\n\n if (doc) {\n // successful getting content\n return doc;\n }\n\n try {\n // simply checking may throw in ie8 under ssl or mismatched protocol\n doc = frame.contentDocument ? frame.contentDocument : frame.document;\n } catch (err) {\n // last attempt\n log(\"cannot get iframe.contentDocument: \" + err);\n doc = frame.document;\n }\n\n return doc;\n}\n\n/** Parses the response text or XML for the given (lowercase) dataType. */\nexport function httpData(xhr, type, s) {\n // mostly lifted from jq1.4.4\n\n var ct = xhr.getResponseHeader(\"content-type\") || \"\",\n xml = (type === \"xml\" || !type) && ct.indexOf(\"xml\") >= 0,\n data = xml ? xhr.responseXML : xhr.responseText;\n\n if (xml && data.documentElement.nodeName === \"parsererror\") {\n if ($.error) {\n $.error(\"parsererror\");\n }\n }\n if (s && s.dataFilter) {\n data = s.dataFilter(data, type);\n }\n if (typeof data === \"string\") {\n if ((type === \"json\" || !type) && ct.indexOf(\"json\") >= 0) {\n data = JSON.parse(data);\n } else if (type === \"script\") {\n $.globalEval(data);\n }\n }\n\n return data;\n}\n\n// Copies the status and statusText attributes of an element onto the mock xhr.\nfunction readStatus(xhr, el) {\n // support for XHR 'status' & 'statusText' emulation :\n xhr.status = Number(el.getAttribute(\"status\")) || xhr.status;\n xhr.statusText = el.getAttribute(\"statusText\") || xhr.statusText;\n}\n\n// Fills the mock xhr from the document itself.\nfunction readDocument(doc, xhr, s, isXml) {\n var docRoot = doc.body ? doc.body : doc.documentElement;\n\n xhr.responseText = docRoot ? docRoot.innerHTML : null;\n xhr.responseXML = doc.XMLDocument ? doc.XMLDocument : doc;\n if (isXml) {\n s.dataType = \"xml\";\n }\n xhr.getResponseHeader = function (header) {\n // the dataType in lowercase, as $.ajax reads it\n var headers = { \"content-type\": s.dataType && s.dataType.toLowerCase() };\n\n return headers[header.toLowerCase()];\n };\n if (docRoot) {\n readStatus(xhr, docRoot);\n }\n}\n\n// A response embedded in a textarea, or text wrapped in pre or body, replaces responseText.\nfunction readEmbedded(doc, xhr, dt, s) {\n var scr = /(json|script|text)/.test(dt);\n\n if (!scr && !s.textarea) {\n return;\n }\n // see if user embedded response in textarea\n var ta = doc.getElementsByTagName(\"textarea\")[0];\n\n if (ta) {\n xhr.responseText = ta.value;\n readStatus(xhr, ta);\n } else if (scr) {\n // account for browsers injecting pre around json response\n var pre = doc.getElementsByTagName(\"pre\")[0];\n var b = doc.getElementsByTagName(\"body\")[0];\n\n if (pre) {\n xhr.responseText = pre.textContent ? pre.textContent : pre.innerText;\n } else if (b) {\n xhr.responseText = b.textContent ? b.textContent : b.innerText;\n }\n }\n}\n\n/**\n * Reads and parses the response document into the mock xhr. Returns {status, data, errMsg}, or\n * null when `retry()` asks to read the document again later (Opera's untraversable DOM).\n */\nexport function readResponse(doc, xhr, s, retry) {\n var status = \"success\",\n data,\n errMsg;\n\n try {\n var isXml = /^xml$/i.test(s.dataType) || doc.XMLDocument || $.isXMLDoc(doc);\n\n log(\"isXml=\" + isXml);\n\n if (!isXml && window.opera && (doc.body === null || !doc.body.innerHTML)) {\n // in some browsers (Opera) the iframe DOM is not always traversable when\n // the onload callback fires, so we loop a bit to accommodate\n if (retry()) {\n return null;\n }\n // let this fall through because server response could be an empty document\n }\n\n readDocument(doc, xhr, s, isXml);\n\n var dt = (s.dataType || \"\").toLowerCase();\n\n readEmbedded(doc, xhr, dt, s);\n\n try {\n data = httpData(xhr, dt, s);\n } catch (err) {\n status = \"parsererror\";\n xhr.error = errMsg = err || status;\n }\n } catch (err) {\n log(\"error caught: \", err);\n status = \"error\";\n xhr.error = errMsg = err;\n }\n\n return { status: status, data: data, errMsg: errMsg };\n}\n","import jQuery from \"jquery\";\nimport { log } from \"./diagnostics.js\";\n\n// The iframe upload's lifecycle: the mock xhr and the Deferred, the global ajax events, the\n// beforeSend veto, the timeout, abort and settling.\nvar $ = jQuery;\n\n/**\n * Creates the lifecycle of one upload with the merged settings `s`. `frame.stop()` stops the\n * frame's load and `frame.release()` removes or resets the frame after the upload.\n */\nexport function createLifecycle(s, frame) {\n var g,\n timeoutHandle,\n callbackProcessed,\n deferred = $.Deferred();\n\n var xhr = {\n // mock object\n aborted: 0,\n responseText: null,\n responseXML: null,\n status: 0,\n statusText: \"n/a\",\n getAllResponseHeaders: function () {},\n getResponseHeader: function () {},\n setRequestHeader: function () {},\n abort: function (status) {\n abort(status, [xhr, \"aborted\", status]);\n },\n };\n\n // #341\n deferred.abort = function (status) {\n xhr.abort(status);\n };\n\n function done() {\n return xhr.aborted || callbackProcessed;\n }\n\n // Completes an aborted upload once and rejects the Deferred with `rejection`.\n // `textStatus` replaces the default \"timeout\"/\"aborted\" text status.\n function abort(status, rejection, textStatus) {\n var e = textStatus || (status === \"timeout\" ? \"timeout\" : \"aborted\");\n\n if (done()) {\n return;\n }\n\n log(\"aborting upload... \" + e);\n xhr.aborted = 1;\n frame.stop();\n xhr.error = e;\n if (s.error) {\n s.error.call(s.context, xhr, e, status);\n }\n deferred.reject.apply(deferred, rejection);\n\n if (g) {\n $.event.trigger(\"ajaxError\", [xhr, s, e]);\n }\n\n complete(e);\n }\n\n // The global events that end every upload, cancelled ones included.\n function endGlobalEvents() {\n if (g) {\n $.event.trigger(\"ajaxComplete\", [xhr, s]);\n }\n\n if (g && !--$.active) {\n $.event.trigger(\"ajaxStop\");\n }\n }\n\n // The steps every finished or aborted upload ends with, in $.ajax order.\n function complete(status) {\n if (s.complete) {\n s.complete.call(s.context, xhr, status);\n }\n\n endGlobalEvents();\n clearTimeout(timeoutHandle);\n\n // clean up\n setTimeout(function () {\n frame.release();\n xhr.responseXML = null;\n }, 100);\n }\n\n // A beforeSend veto ends the upload as $.ajax cancels a request: no callbacks, the global\n // events end with ajaxError \"canceled\".\n function cancel() {\n if (done()) {\n return;\n }\n\n callbackProcessed = true;\n deferred.reject();\n if (g) {\n $.event.trigger(\"ajaxError\", [xhr, s, \"canceled\"]);\n }\n endGlobalEvents();\n }\n\n // Fires the start events and beforeSend; false when the upload must not be posted.\n function start() {\n g = s.global;\n // trigger ajax global events so that activity/block indicators work like normal\n if (g && $.active++ === 0) {\n $.event.trigger(\"ajaxStart\");\n }\n\n if (s.beforeSend && s.beforeSend.call(s.context, xhr, s) === false) {\n cancel();\n\n return false;\n }\n\n if (xhr.aborted) {\n // abort() in beforeSend already completed the upload\n return false;\n }\n\n if (g) {\n $.event.trigger(\"ajaxSend\", [xhr, s]);\n }\n\n // an ajaxSend handler may abort too\n return !xhr.aborted;\n }\n\n // Resolves the upload; returns {error} when the success callback threw.\n function succeed(data) {\n var failure;\n\n try {\n s.success.call(s.context, data, \"success\", xhr);\n } catch (err) {\n failure = { error: err };\n }\n\n deferred.resolve(xhr.responseText, \"success\", xhr);\n\n if (g) {\n $.event.trigger(\"ajaxSuccess\", [xhr, s, data]);\n }\n\n return failure;\n }\n\n // Settles the upload with the response reader's {status, data, errMsg}.\n function settle(result) {\n var status = result.status,\n errMsg = result.errMsg;\n\n if (xhr.aborted) {\n // abort() completed the upload while its response was processed\n log(\"upload aborted\");\n\n return;\n }\n\n // an emulated HTTP error status wins, as in $.ajax; a parse error is kept otherwise\n if (xhr.status && !((xhr.status >= 200 && xhr.status < 300) || xhr.status === 304)) {\n status = \"error\";\n }\n\n callbackProcessed = true;\n\n // ordering of these callbacks/triggers is odd, but that's how $.ajax does it\n if (status === \"success\") {\n var failure = succeed(result.data);\n\n complete(status);\n if (failure) {\n // the upload is settled; the success callback's exception still reaches the console\n throw failure.error;\n }\n\n return;\n }\n\n if (typeof errMsg === \"undefined\") {\n errMsg = xhr.statusText;\n }\n if (s.error) {\n s.error.call(s.context, xhr, status, errMsg);\n }\n deferred.reject(xhr, \"error\", errMsg);\n if (g) {\n $.event.trigger(\"ajaxError\", [xhr, s, errMsg]);\n }\n\n complete(status);\n }\n\n return {\n xhr: xhr,\n deferred: deferred,\n start: start,\n done: done,\n abort: abort,\n settle: settle,\n // Settles an upload that failed with an exception (ignored once aborted).\n fail: function (err) {\n settle({ status: \"error\", errMsg: err });\n },\n // Runs `onTimeout` after s.timeout, when set.\n startTimer: function (onTimeout) {\n if (s.timeout) {\n timeoutHandle = setTimeout(onTimeout, s.timeout);\n }\n },\n stopTimer: function () {\n clearTimeout(timeoutHandle);\n timeoutHandle = undefined;\n },\n };\n}\n","import {\n addCsrfField,\n addExtraInputs,\n addSubmitterFields,\n restoreAttributes,\n saveAttributes,\n setUploadAttributes,\n submitForm,\n} from \"./iframe-post.js\";\nimport { closestByTag, formMember } from \"./form-members.js\";\nimport { deprecate, log } from \"./diagnostics.js\";\nimport { getDoc, readResponse } from \"./iframe-response.js\";\nimport { createLifecycle } from \"./iframe-lifecycle.js\";\nimport jQuery from \"jquery\";\nimport { keepContext } from \"./options.js\";\n\n// The iframe transport: posts the form itself into a hidden frame and reads the response from it,\n// for file uploads without the File API or when the iframe option asks for it.\nvar $ = jQuery;\n\n/**\n * The iframe send step. `hasProp` is what the entry detected at load; `forms.property` reads a\n * form property as attr2 does.\n */\nexport function createIframeTransport(hasProp, forms) {\n var CLIENT_TIMEOUT_ABORT = 1;\n var SERVER_ABORT = 2;\n // tells apart the frames of uploads that start in the same millisecond\n var frameCount = 0;\n\n // ensure that every serialized input is still enabled\n function enableControls(elements) {\n for (var i = 0; i < elements.length; i++) {\n var el = $(elements[i]);\n\n if (hasProp) {\n el.prop(\"disabled\", false);\n } else {\n el.removeAttr(\"disabled\");\n }\n }\n }\n\n // Names the frame's window, when the page may: a cross-origin or sandboxed frame refuses.\n function nameWindow(frame, name) {\n try {\n if (frame.contentWindow) {\n frame.contentWindow.name = name;\n }\n } catch (ignore) {}\n }\n\n // The frame the form posts into: the iframeTarget, named `id` when it has no name, or a new\n // hidden frame named `id`. Returns the frame and the name the form targets.\n function createFrame(s, id, ownerDocument) {\n var $io, n;\n\n if (s.iframeTarget) {\n $io = $(s.iframeTarget, ownerDocument);\n n = $io.attr(\"name\");\n if (!n) {\n $io.attr(\"name\", id);\n // a frame already in the page keeps the browsing context name it was inserted with\n $io.each(function () {\n nameWindow(this, id);\n });\n } else {\n id = n;\n }\n } else {\n var io = ownerDocument.createElement(\"iframe\");\n\n io.setAttribute(\"name\", id);\n io.setAttribute(\"src\", s.iframeSrc);\n $io = $(io);\n $io.css({ position: \"absolute\", top: \"-1000px\", left: \"-1000px\" });\n }\n\n return { $io: $io, id: id };\n }\n\n // The frame hooks the lifecycle calls: stop a load in progress, and release after the upload.\n function frameHooks(s, $io) {\n return {\n stop: function () {\n try {\n // #214, #257\n if ($io[0].contentWindow.document.execCommand) {\n $io[0].contentWindow.document.execCommand(\"Stop\");\n }\n } catch (ignore) {}\n\n $io.attr(\"src\", s.iframeSrc); // abort op in progress\n },\n release: function () {\n if (!s.iframeTarget) {\n $io.remove();\n } else {\n // adding else to clean up existing iframe response.\n $io.attr(\"src\", s.iframeSrc);\n }\n },\n };\n }\n\n function listen(io, cb) {\n if (io.attachEvent) {\n io.attachEvent(\"onload\", cb);\n } else {\n io.addEventListener(\"load\", cb, false);\n }\n }\n\n function unlisten(io, cb) {\n if (io.detachEvent) {\n io.detachEvent(\"onload\", cb);\n } else {\n io.removeEventListener(\"load\", cb, false);\n }\n }\n\n // private function for handling file uploads (hat tip to YAHOO!)\n function fileUploadIframe(submission) {\n var form = submission.form,\n method = submission.method;\n\n var s = keepContext($.extend(true, {}, $.ajaxSettings, submission.options), [\n $.ajaxSettings,\n submission.options,\n ]);\n\n s.context = s.context || s;\n var ownerDocument = formMember(form, \"ownerDocument\");\n var $body = $(closestByTag(form, [\"body\"]));\n var frame = createFrame(s, \"jqFormIO\" + new Date().getTime() + frameCount++, ownerDocument);\n var $io = frame.$io,\n io = $io[0];\n var life = createLifecycle(s, frameHooks(s, $io));\n var domCheckCount = 50;\n\n if (!life.start()) {\n return life.deferred;\n }\n\n addSubmitterFields(s, form);\n addCsrfField(s, form, method, forms);\n\n // look for server aborts\n function checkState() {\n try {\n var state = getDoc(io).readyState;\n\n log(\"state = \" + state);\n if (state && state.toLowerCase() === \"uninitialized\") {\n setTimeout(checkState, 50);\n }\n } catch (e) {\n log(\"Server abort: \", e, \" (\", e.name, \")\");\n cb(SERVER_ABORT);\n life.stopTimer();\n }\n }\n\n // take a breath so that pending repaints get some cpu time before the upload starts\n function doSubmit() {\n var saved = saveAttributes(form);\n\n setUploadAttributes(form, frame.id, method, s, forms);\n\n // support timout\n life.startTimer(function () {\n cb(CLIENT_TIMEOUT_ABORT);\n });\n\n // add \"extra\" data to form if provided in options\n var extraInputs = [];\n\n try {\n addExtraInputs(form, ownerDocument, s.extraData, submission.traditional, extraInputs);\n\n if (!s.iframeTarget) {\n // add iframe to doc and submit the form\n $io.appendTo($body);\n }\n\n // A connected form posting into a frame outside the document opens a new window.\n var root = ownerDocument.documentElement;\n\n if (io && $.contains(root, form) && !$.contains(root, io)) {\n var notInDocument = \"jquery.form: the upload frame is not in the document\";\n\n life.abort(notInDocument, [life.xhr, \"error\", notInDocument], \"error\");\n\n return;\n }\n\n listen(io, cb);\n setTimeout(checkState, 15);\n submitForm(form);\n } finally {\n // reset attrs and remove \"extra\" input elements\n restoreAttributes(form, saved);\n $(extraInputs).remove();\n }\n }\n\n // Reads the next document by Opera's rules: false once the retries are used up.\n function retry() {\n if (--domCheckCount) {\n log(\"requeing onLoad callback, DOM not available\");\n setTimeout(cb, 250);\n\n return true;\n }\n\n return false;\n }\n\n function cb(e) {\n if (life.done()) {\n return;\n }\n\n var doc = getDoc(io);\n\n if (!doc) {\n log(\"cannot access response document\");\n e = SERVER_ABORT;\n }\n if (e === CLIENT_TIMEOUT_ABORT) {\n life.abort(\"timeout\", [life.xhr, \"timeout\"]);\n\n return;\n }\n if (e === SERVER_ABORT) {\n life.abort(\"server abort\", [life.xhr, \"error\", \"server abort\"]);\n\n return;\n }\n\n if (doc.location.href === s.iframeSrc) {\n // response not received yet\n return;\n }\n\n unlisten(io, cb);\n\n var result = readResponse(doc, life.xhr, s, retry);\n\n if (result) {\n life.settle(result);\n }\n }\n\n // An exception while posting settles the upload with \"error\" and the exception.\n function post() {\n if (life.done()) {\n // aborted before the delayed post\n return;\n }\n\n try {\n doSubmit();\n } catch (err) {\n log(\"upload failed: \", err);\n life.fail(err);\n }\n }\n\n if (s.forceSync) {\n post();\n } else {\n setTimeout(post, 10); // this lets dom updates render\n }\n\n return life.deferred;\n }\n\n return function sendIframe(submission) {\n var jqxhr;\n\n // now, while the controls are still listed: ajaxSubmit clears the list when it returns,\n // before a closeKeepAlive request completes\n enableControls(submission.controls);\n\n // hack to fix Safari hang (thanks to Tim Molendijk for this)\n // see: http://groups.google.com/group/jquery-dev/browse_thread/thread/36395b7ab510dd5d\n if (submission.options.closeKeepAlive) {\n deprecate(\"closeKeepAlive\", \"closeKeepAlive works around a Safari 3/4 bug and is deprecated\");\n $.get(submission.options.closeKeepAlive, function () {\n jqxhr = fileUploadIframe(submission);\n });\n } else {\n jqxhr = fileUploadIframe(submission);\n }\n\n return jqxhr;\n };\n}\n","import { deprecate, log } from \"./diagnostics.js\";\nimport { assertRealParent } from \"./form-members.js\";\nimport jQuery from \"jquery\";\nimport { keepContext } from \"./options.js\";\nimport { urlencodedFields } from \"./successful-controls.js\";\n\n// A Submission is one ajaxSubmit call once its vetoes have passed:\n// { form, $form, fields, controls, options, method, traditional }. `options` is the object the\n// callbacks and events receive; later steps change it in place.\n\n/**\n * The submission steps. `feature` holds what the entry detected at load (fileapi, formdata), and\n * `forms` reads form attributes and attr2-style properties (attribute, property), and\n * `serialization` collects the form's fields and controls.\n */\nexport function createSubmission(feature, forms, serialization) {\n var $ = jQuery;\n\n function refuse(message) {\n log(message);\n\n return null;\n }\n\n // The options merged over the form's action, the method, and the ajax defaults.\n function withDefaults(form, options, method) {\n var action = options.url || forms.property(form, \"action\");\n var url = typeof action === \"string\" ? action.trim() : \"\";\n\n // clean url (don't include hash value); an action that is only a fragment means this page\n url = url.split(\"#\")[0] || window.location.href.split(\"#\")[0];\n // IE requires javascript:false in https, but this breaks chrome >83 and goes against spec.\n // Instead of using javascript:false always, let's only apply it for IE.\n var isMsie = /(MSIE|Trident)/.test(navigator.userAgent || \"\");\n var iframeSrc = isMsie && /^https/i.test(document.URL) ? \"javascript:false\" : \"about:blank\"; // eslint-disable-line no-script-url\n\n var merged = $.extend(\n true,\n {\n url: url,\n success: $.ajaxSettings.success,\n type: method || $.ajaxSettings.type,\n iframeSrc: iframeSrc,\n },\n options\n );\n\n return keepContext(merged, [options]);\n }\n\n /**\n * The one method every transport sends, read after the hooks: `method` wins over `type`, and\n * `type` is set to it. Undefined when only the ajax default applies, so each transport keeps\n * its own default.\n */\n function resolveMethod(options, defaultType) {\n var resolved = options.method || options.type;\n\n options.type = resolved;\n\n return resolved === defaultType && !options.method ? undefined : resolved;\n }\n\n // The data option, kept as extraData and encoded, or undefined without one.\n function extraQuery(fields, options, traditional) {\n if (!options.data) {\n return undefined;\n }\n\n var optionsData = typeof options.data === \"function\" ? options.data(fields) : options.data;\n\n if (typeof optionsData === \"string\") {\n if (options.requestFormat === \"json\") {\n throw new Error(\n 'jquery.form: requestFormat \"json\" needs object data; a string data option is a query string'\n );\n }\n\n // a query string: sent as-is when urlencoded, as its own fields otherwise\n options.extraData = queryPairs(optionsData);\n\n return optionsData;\n }\n\n options.extraData = optionsData;\n\n return $.param(optionsData, traditional);\n }\n\n // Sets a key as an own data property, so a name like __proto__ is an ordinary key.\n function defineKey(object, key, value) {\n Object.defineProperty(object, key, {\n value: value,\n enumerable: true,\n writable: true,\n configurable: true,\n });\n }\n\n /**\n * requestFormat \"json\" (#545): the fields as an object (a repeated name gives an array), merged\n * with object data, sent as a JSON body. Based on the idea in PR #557 by zhangciwu.\n */\n function jsonBody(options, fields) {\n if (/^get$/i.test(options.type)) {\n throw new Error('jquery.form: requestFormat \"json\" needs a method with a body, such as POST');\n }\n\n var body = {};\n var own = Object.prototype.hasOwnProperty;\n\n for (var i = 0; i < fields.length; i++) {\n var name = fields[i].name;\n\n if (!own.call(body, name)) {\n defineKey(body, name, fields[i].value);\n } else if (Array.isArray(body[name])) {\n body[name].push(fields[i].value);\n } else {\n defineKey(body, name, [body[name], fields[i].value]);\n }\n }\n\n var extra = options.extraData;\n\n for (var key in extra) {\n if (own.call(extra, key)) {\n defineKey(body, key, extra[key]);\n }\n }\n\n options.data = JSON.stringify(body);\n options.contentType = \"application/json; charset=UTF-8\";\n }\n\n // The fields of a query string, as the { name, value } list $.param takes.\n function queryPairs(query) {\n var pairs = [];\n var parts = query.split(\"&\");\n\n for (var i = 0; i < parts.length; i++) {\n if (parts[i]) {\n var at = parts[i].indexOf(\"=\");\n var name = at < 0 ? parts[i] : parts[i].slice(0, at);\n var value = at < 0 ? \"\" : parts[i].slice(at + 1);\n\n pairs.push({ name: decodeQuery(name), value: decodeQuery(value) });\n }\n }\n\n return pairs;\n }\n\n function decodeQuery(text) {\n return decodeURIComponent(text.replace(/\\+/g, \" \"));\n }\n\n // Puts the encoded fields in the url for a get, and in the data otherwise.\n function encode(options, q, qx) {\n if (qx) {\n q = q ? q + \"&\" + qx : qx;\n }\n\n if (options.type.toUpperCase() === \"GET\") {\n // the query goes before any fragment in the url option\n var hashAt = options.url.indexOf(\"#\");\n var base = hashAt < 0 ? options.url : options.url.slice(0, hashAt);\n\n options.url =\n base + (base.indexOf(\"?\") >= 0 ? \"&\" : \"?\") + q + options.url.slice(base.length);\n options.data = null; // data is null for 'get'\n } else {\n options.data = q; // data is the query string for 'post'\n }\n }\n\n // A callback option as a list: an array as given, one function, or none.\n function callbackList(callback) {\n if (Array.isArray(callback)) {\n return callback;\n }\n\n return callback ? [callback] : [];\n }\n\n // Calls each callback in order with the same this and arguments.\n function callEach(callbacks, context, args) {\n for (var i = 0; i < callbacks.length; i++) {\n callbacks[i].apply(context, args);\n }\n }\n\n /**\n * Resolves the options, serializes the form, and runs the vetoes: the Submission, or null when\n * an event or callback stopped it.\n */\n function prepare($set, options) {\n $set.each(function () {\n assertRealParent(this);\n });\n\n var form = $set[0];\n var method = options.method || options.type || forms.property(form, \"method\");\n\n options = withDefaults(form, options, method);\n\n // the ajax default type, when neither the caller nor the form gave a method\n var defaultType = method ? undefined : options.type;\n\n // hook for manipulating the form data before it is extracted;\n // convenient for use with rich editors like tinyMCE or FCKEditor\n var veto = {};\n\n $set.trigger(\"form-pre-serialize\", [$set, options, veto]);\n if (veto.veto) {\n return refuse(\"ajaxSubmit: submit vetoed via form-pre-serialize trigger\");\n }\n\n // provide opportunity to alter form data before it is serialized\n if (options.beforeSerialize && options.beforeSerialize($set, options) === false) {\n return refuse(\"ajaxSubmit: submit aborted via beforeSerialize callback\");\n }\n\n var traditional = options.traditional;\n\n if (typeof traditional === \"undefined\") {\n traditional = $.ajaxSettings.traditional;\n }\n\n var collected = serialization.collect($set[0], options.semantic, options.filtering);\n var fields = collected.fields;\n var controls = collected.controls;\n var qx = extraQuery(fields, options, traditional);\n\n // give pre-submit callback an opportunity to abort the submit\n if (options.beforeSubmit && options.beforeSubmit(fields, $set, options) === false) {\n return refuse(\"ajaxSubmit: submit aborted via beforeSubmit callback\");\n }\n\n // fire vetoable 'validate' event\n $set.trigger(\"form-submit-validate\", [fields, $set, options, veto]);\n if (veto.veto) {\n return refuse(\"ajaxSubmit: submit vetoed via form-submit-validate trigger\");\n }\n\n method = resolveMethod(options, defaultType);\n\n if (options.requestFormat === \"json\") {\n jsonBody(options, fields);\n } else {\n encode(options, $.param(urlencodedFields(fields), traditional), qx);\n }\n\n return {\n form: form,\n $form: $set,\n fields: fields,\n controls: controls,\n options: options,\n method: method,\n traditional: traditional,\n };\n }\n\n /**\n * Wraps success, error and complete (a function or an array of them, as $.ajax takes) so each\n * also receives the form, and adds the resetForm,\n * clearForm and target steps before the success callbacks.\n */\n function deliver(submission) {\n var $set = submission.$form;\n var options = submission.options;\n var callbacks = [];\n\n if (options.resetForm) {\n callbacks.push(function () {\n $set.resetForm();\n });\n }\n\n if (options.clearForm) {\n callbacks.push(function () {\n $set.clearForm(options.includeHidden);\n });\n }\n\n // perform a load on the target only if dataType is not provided\n if (!options.dataType && options.target) {\n var successes = callbackList(options.success);\n\n callbacks.push(function (data, textStatus, jqXHR) {\n var successArguments = arguments,\n fn = options.replaceTarget ? \"replaceWith\" : \"html\",\n $target = $(options.target);\n\n // Only a string response is inserted. jQuery has already parsed a JSON or XML response,\n // and inserting it would parse each of its strings as HTML.\n if (typeof data === \"string\") {\n $target[fn](data);\n } else {\n log(\"target: the response was parsed by jQuery, so it is not inserted\");\n }\n\n if (!$target.length) {\n // nothing to fill: success still runs once, with the normal context\n callEach(successes, this, successArguments);\n }\n\n $target.each(function () {\n callEach(successes, this, successArguments);\n });\n });\n } else {\n $.merge(callbacks, callbackList(options.success));\n }\n\n options.success = function (data, status, xhr) {\n // jQuery 1.4+ passes xhr as 3rd arg\n var context = options.context || this; // jQuery 1.4+ supports scope context\n\n for (var i = 0, max = callbacks.length; i < max; i++) {\n callbacks[i].apply(context, [data, status, xhr || $set, $set]);\n }\n };\n\n if (options.error) {\n var errors = callbackList(options.error);\n\n options.error = function (xhr, status, error) {\n callEach(errors, options.context || this, [xhr, status, error, $set]);\n };\n }\n\n if (options.complete) {\n var completes = callbackList(options.complete);\n\n options.complete = function (xhr, status) {\n callEach(completes, options.context || this, [xhr, status, $set]);\n };\n }\n }\n\n /**\n * The transport for a submission: \"iframe\" for files without the File API or when forced,\n * \"formdata\" for files with it, \"ajax\" otherwise.\n */\n function chooseTransport(submission) {\n var $set = submission.$form;\n var options = submission.options;\n\n // [value] (issue #113), also see comment:\n // https://github.com/malsup/form/commit/588306aedba1de01388032d5f42a60159eea9228#commitcomment-2180219\n // and the file inputs outside the form that belong to it through their form attribute\n var fileInputs = $(\"input[type=file]:enabled\", $set)\n .add($(submission.controls).filter(\"input[type=file]\"))\n .filter(function () {\n return $(this).val() !== \"\";\n });\n var hasFileInputs = fileInputs.length > 0;\n // compared as the browser does: ASCII case-insensitive, without surrounding whitespace\n var mp = /^[\\t\\n\\f\\r ]*multipart\\/form-data[\\t\\n\\f\\r ]*$/i;\n var multipart =\n mp.test(forms.attribute($set[0], \"enctype\")) || mp.test(forms.attribute($set[0], \"encoding\"));\n var fileAPI = feature.fileapi && feature.formdata;\n\n log(\"fileAPI :\" + fileAPI);\n\n var shouldUseFrame = (hasFileInputs || multipart) && !fileAPI;\n\n var transport = (hasFileInputs || multipart) && fileAPI ? \"formdata\" : \"ajax\";\n\n // options.iframe allows user to force iframe mode\n // 06-NOV-09: now defaulting to iframe mode if file input is detected\n if (options.iframe !== false && (options.iframe || shouldUseFrame)) {\n transport = \"iframe\";\n }\n\n if (transport === \"iframe\" && !options.iframe) {\n deprecate(\n \"iframe\",\n \"choosing the iframe transport automatically without FormData is deprecated, set iframe: true\"\n );\n }\n\n if (transport !== \"ajax\" && options.requestFormat === \"json\") {\n throw new Error(\n 'jquery.form: requestFormat \"json\" cannot send files or use the iframe transport'\n );\n }\n\n return transport;\n }\n\n return { prepare: prepare, deliver: deliver, chooseTransport: chooseTransport };\n}\n","/*!\n * jQuery Form Plugin\n * version: 4.5.0\n * Requires jQuery v1.7.2 or later\n * Project repository: https://github.com/jquery-form/form\n\n * Copyright 2017 Kevin Morris\n * Copyright 2006 M. Alsup\n\n * Dual licensed under the LGPL-2.1+ or MIT licenses\n * https://github.com/jquery-form/form#license\n\n * This library is free software; you can redistribute it and/or\n * modify it under the terms of the GNU Lesser General Public\n * License as published by the Free Software Foundation; either\n * version 2.1 of the License, or (at your option) any later version.\n * This library is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Lesser General Public License for more details.\n */\nimport { ajaxForm, ajaxFormUnbind } from \"./ajax-form.js\";\nimport { callFormMethod, tagName } from \"./form-members.js\";\nimport {\n createSuccessfulControls,\n isSuccessful,\n urlencodedFields,\n valueOf,\n} from \"./successful-controls.js\";\nimport { deprecate, deprecateOldJQuery, log } from \"./diagnostics.js\";\nimport { sendAjax, sendFormData } from \"./xhr-transport.js\";\nimport { createIframeTransport } from \"./iframe-transport.js\";\nimport { createSubmission } from \"./submission.js\";\nimport { formAttribute } from \"./form-attributes.js\";\nimport jQuery from \"jquery\";\nimport { submitOptions } from \"./options.js\";\nimport { submitterElement } from \"./submitter.js\";\n\n(function ($) {\n \"use strict\";\n\n /*\n\t\tUsage Note:\n\t\t-----------\n\t\tDo not use both ajaxSubmit and ajaxForm on the same form. These\n\t\tfunctions are mutually exclusive. Use ajaxSubmit if you want\n\t\tto bind your own submit handler to the form. For example,\n\n\t\t$(document).ready(function() {\n\t\t\t$('#myForm').on('submit', function(e) {\n\t\t\t\te.preventDefault(); // <-- important\n\t\t\t\t$(this).ajaxSubmit({\n\t\t\t\t\ttarget: '#output'\n\t\t\t\t});\n\t\t\t});\n\t\t});\n\n\t\tUse ajaxForm when you want the plugin to manage all the event binding\n\t\tfor you. For example,\n\n\t\t$(document).ready(function() {\n\t\t\t$('#myForm').ajaxForm({\n\t\t\t\ttarget: '#output'\n\t\t\t});\n\t\t});\n\n\t\tYou can also use ajaxForm with delegation (requires jQuery v1.7+), so the\n\t\tform does not have to exist when you invoke ajaxForm:\n\n\t\t$('#myForm').ajaxForm({\n\t\t\tdelegation: true,\n\t\t\ttarget: '#output'\n\t\t});\n\n\t\tWhen using ajaxForm, the ajaxSubmit function will be invoked for you\n\t\tat the appropriate time.\n\t*/\n\n /**\n * Feature detection\n */\n var feature = {};\n\n feature.fileapi = $('').get(0).files !== undefined;\n feature.formdata = typeof window.FormData !== \"undefined\";\n\n var hasProp = !!$.fn.prop;\n // What attr2 returns for a form: the property when it is a string, otherwise the attribute. The\n // property is read plainly on purpose: a control named like it shadows it, and then the raw\n // attribute is used.\n function formProperty(form, name) {\n var value = hasProp ? form[name] : undefined;\n\n return typeof value === \"string\" ? value : formAttribute(form, name);\n }\n\n var forms = { attribute: formAttribute, property: formProperty };\n var serialization = createSuccessfulControls(feature);\n var steps = createSubmission(feature, forms, serialization);\n var transports = {\n iframe: createIframeTransport(hasProp, forms),\n formdata: sendFormData,\n ajax: sendAjax,\n };\n\n // attr2 uses prop when it can but checks the return type for\n // an expected string. This accounts for the case where a form\n // contains inputs with names like \"action\" or \"method\"; in those\n // cases \"prop\" returns the element\n $.fn.attr2 = function () {\n deprecate(\"attr2\", \"attr2 is deprecated, use .prop() or .attr()\");\n\n if (!hasProp) {\n return this.attr.apply(this, arguments);\n }\n\n var val = this.prop.apply(this, arguments);\n\n if ((val && val.jquery) || typeof val === \"string\") {\n return val;\n }\n\n return this.attr.apply(this, arguments);\n };\n\n /**\n * ajaxSubmit() provides a mechanism for immediately submitting\n * an HTML form using AJAX.\n *\n * @param\t{object|string}\toptions\t\tjquery.form.js parameters or custom url for submission\n * @param\t{object}\t\tdata\t\textraData\n * @param\t{string}\t\tdataType\tajax dataType\n * @param\t{function}\t\tonSuccess\tajax success callback function\n */\n $.fn.ajaxSubmit = function (options, data, dataType, onSuccess) {\n deprecateOldJQuery($.fn.jquery);\n\n // fast fail if nothing selected (http://dev.jquery.com/ticket/2752)\n if (!this.length) {\n log(\"ajaxSubmit: skipping submit process - no element selected\");\n\n return this;\n }\n\n // #541: jQuery's slim build has no $.ajax\n if (!$.ajax) {\n throw new Error(\n \"jquery.form: ajaxSubmit needs the full jQuery build; this jQuery has no $.ajax\"\n );\n }\n\n var submission = steps.prepare(this, submitOptions(options, data, dataType, onSuccess));\n\n if (!submission) {\n return this;\n }\n\n steps.deliver(submission);\n\n var jqxhr = transports[steps.chooseTransport(submission)](submission);\n\n this.removeData(\"jqxhr\").data(\"jqxhr\", jqxhr);\n\n // clear element array\n for (var k = 0; k < submission.controls.length; k++) {\n submission.controls[k] = null;\n }\n\n // fire 'notify' event\n this.trigger(\"form-submit-notify\", [this, submission.options]);\n\n return this;\n };\n\n $.fn.ajaxForm = ajaxForm;\n $.fn.ajaxFormUnbind = ajaxFormUnbind;\n\n /**\n * formToArray() gathers form element data into an array of objects that can\n * be passed to any of the following ajax functions: $.get, $.post, or load.\n * Each object in the array has both a 'name' and 'value' property. An example of\n * an array for a simple login form might be:\n *\n * [ { name: 'username', value: 'jresig' }, { name: 'password', value: 'secret' } ]\n *\n * It is this array that is passed to pre-submit callback functions provided to the\n * ajaxSubmit() and ajaxForm() methods.\n */\n $.fn.formToArray = function (semantic, elements, filtering) {\n var collected = serialization.collect(this[0], semantic, filtering);\n\n if (elements) {\n elements.push.apply(elements, collected.controls);\n }\n\n return collected.fields;\n };\n\n /**\n * Serializes form data into a 'submittable' string. This method will return a string\n * in the format: name1=value1&name2=value2\n */\n $.fn.formSerialize = function (semantic) {\n // hand off to jQuery.param for proper encoding\n return $.param(urlencodedFields(this.formToArray(semantic)));\n };\n\n /**\n * Serializes all field elements in the jQuery object into a query string.\n * This method will return a string in the format: name1=value1&name2=value2\n */\n $.fn.fieldSerialize = function (successful) {\n var a = [];\n\n this.each(function () {\n var n = this.name;\n\n // a form is not a field, though it may have a name\n if (!n || tagName(this) === \"form\") {\n return;\n }\n\n var v = $.fieldValue(this, successful);\n\n if (v && v.constructor === Array) {\n for (var i = 0, max = v.length; i < max; i++) {\n a.push({ name: n, value: v[i] });\n }\n } else if (v !== null && typeof v !== \"undefined\") {\n a.push({ name: this.name, value: v });\n }\n });\n\n // hand off to jQuery.param for proper encoding\n return $.param(a);\n };\n\n /**\n * Returns the value(s) of the element in the matched set. For example, consider the following form:\n *\n *\t
\n *\t\t\n *\t\t\n *\t\t\n *\t\t\n *\t\t\n *\t\t\n *\t
\n *\n *\tvar v = $('input[type=text]').fieldValue();\n *\t// if no values are entered into the text inputs\n *\tv === ['','']\n *\t// if values entered into the text inputs are 'foo' and 'bar'\n *\tv === ['foo','bar']\n *\n *\tvar v = $('input[type=checkbox]').fieldValue();\n *\t// if neither checkbox is checked\n *\tv === undefined\n *\t// if both checkboxes are checked\n *\tv === ['B1', 'B2']\n *\n *\tvar v = $('input[type=radio]').fieldValue();\n *\t// if neither radio is checked\n *\tv === undefined\n *\t// if first radio is checked\n *\tv === ['C1']\n *\n * The successful argument controls whether or not the field element must be 'successful'\n * (per http://www.w3.org/TR/html4/interact/forms.html#successful-controls).\n * The default value of the successful argument is true. If this value is false the value(s)\n * for each element is returned.\n *\n * Note: This method *always* returns an array. If no valid value can be determined the\n *\tarray will be empty, otherwise it will contain one or more values.\n */\n $.fn.fieldValue = function (successful) {\n for (var val = [], i = 0, max = this.length; i < max; i++) {\n var el = this[i];\n var v = $.fieldValue(el, successful);\n\n if (v === null || typeof v === \"undefined\" || (v.constructor === Array && !v.length)) {\n continue;\n }\n\n if (v.constructor === Array) {\n $.merge(val, v);\n } else {\n val.push(v);\n }\n }\n\n return val;\n };\n\n /**\n * Returns the value of the field element.\n */\n $.fieldValue = function (el, successful) {\n var required = typeof successful === \"undefined\" || successful;\n\n if (required && !isSuccessful(el, submitterElement(el.form))) {\n return null;\n }\n\n return valueOf(el);\n };\n\n /**\n * Clears the form data. Takes the following actions on the form's input fields:\n * - input text fields will have their 'value' property set to the empty string\n * - select elements will have their 'selectedIndex' property set to -1\n * - checkbox and radio inputs will have their 'checked' property set to false\n * - inputs of type submit, button, reset, and hidden will *not* be effected\n * - button elements will *not* be effected\n */\n $.fn.clearForm = function (includeHidden) {\n return this.each(function () {\n $(\"input,select,textarea\", this).clearFields(includeHidden);\n });\n };\n\n /**\n * Clears the selected form elements.\n */\n $.fn.clearInputs = function (includeHidden) {\n deprecate(\"clearInputs\", \"clearInputs is deprecated, use clearFields\");\n\n return this.clearFields(includeHidden);\n };\n\n $.fn.clearFields = function (includeHidden) {\n var re =\n /^(?:color|date|datetime|datetime-local|email|month|number|password|range|search|tel|text|time|url|week)$/i; // 'hidden' is not in this list\n\n return this.each(function () {\n var t = this.type,\n tag = tagName(this);\n\n if (re.test(t) || tag === \"textarea\") {\n this.value = \"\";\n } else if (t === \"checkbox\" || t === \"radio\") {\n this.checked = false;\n } else if (tag === \"select\") {\n this.selectedIndex = -1;\n } else if (t === \"file\") {\n if (/MSIE/.test(navigator.userAgent)) {\n $(this).replaceWith($(this).clone(true));\n } else {\n $(this).val(\"\");\n }\n } else if (includeHidden) {\n // includeHidden can be the value true, or it can be a selector string\n // indicating a special test; for example:\n // $('#myForm').clearForm('.special:hidden')\n // the above would clean hidden inputs that have the class of 'special'\n if (\n (includeHidden === true && /hidden/.test(t)) ||\n (typeof includeHidden === \"string\" && $(this).is(includeHidden))\n ) {\n this.value = \"\";\n }\n }\n });\n };\n\n /**\n * Resets the form data or individual elements. Takes the following actions\n * on the selected tags:\n * - all fields within form elements will be reset to their original value\n * - input / textarea / select fields will be reset to their original value\n * - option / optgroup fields (for multi-selects) will defaulted individually\n * - non-multiple options will find the right select to default\n * - label elements will be searched against its 'for' attribute\n * - all others will be searched for appropriate children to default\n */\n $.fn.resetForm = function () {\n return this.each(function () {\n var el = $(this);\n var tag = tagName(this);\n\n switch (tag) {\n case \"input\":\n this.checked = this.defaultChecked;\n\n // as the native reset: types whose value is the value attribute keep it\n if (this.type === \"file\") {\n // a file input cannot take its value attribute; the native reset empties it\n this.value = \"\";\n } else if (!/^(?:checkbox|radio|hidden|submit|reset|button|image)$/.test(this.type)) {\n this.value = this.defaultValue;\n }\n\n return true;\n\n case \"textarea\":\n this.value = this.defaultValue;\n\n return true;\n\n case \"option\":\n case \"optgroup\":\n var select = el.parents(\"select\");\n\n if (select.length && select[0].multiple) {\n if (tag === \"option\") {\n this.selected = this.defaultSelected;\n } else {\n el.find(\"option\").resetForm();\n }\n } else {\n select.resetForm();\n }\n\n return true;\n\n case \"select\":\n // in order, as the native reset: of several default options, a single select keeps the last\n el.find(\"option\").each(function () {\n this.selected = this.defaultSelected;\n });\n\n return true;\n\n case \"label\":\n // The control whose id the for attribute names, and the controls inside the label. The\n // filter keeps a for that names an ancestor from resetting the label again.\n var forEl = this.htmlFor && this.ownerDocument.getElementById(this.htmlFor);\n\n el.find(\"input,select,textarea\").add(forEl).filter(\"input,select,textarea\").resetForm();\n\n return true;\n\n case \"form\":\n // through the prototype: a control named reset shadows the method\n callFormMethod(this, \"reset\");\n\n return true;\n\n default:\n el.find(\"form,input,label,select,textarea\").resetForm();\n\n return true;\n }\n });\n };\n\n /**\n * Enables or disables any matching elements.\n */\n $.fn.enable = function (b) {\n if (typeof b === \"undefined\") {\n b = true;\n }\n\n return this.each(function () {\n this.disabled = !b;\n });\n };\n\n /**\n * Checks/unchecks any matching checkboxes or radio buttons and\n * selects/deselects and matching option elements.\n */\n $.fn.selected = function (select) {\n if (typeof select === \"undefined\") {\n select = true;\n }\n\n return this.each(function () {\n var t = this.type;\n\n if (t === \"checkbox\" || t === \"radio\") {\n this.checked = select;\n } else if (tagName(this) === \"option\") {\n var $sel = $(this).parent(\"select\");\n\n if (select && $sel[0] && $sel[0].type === \"select-one\") {\n // deselect all other options\n $sel.find(\"option\").selected(false);\n }\n\n this.selected = select;\n }\n });\n };\n\n // expose debug var\n $.fn.ajaxSubmit.debug = false;\n})(jQuery);\n\nexport default jQuery;\n"],"names":["owners","plainForm","document","createElement","findDescriptor","name","i","length","owner","window","descriptor","Object","getOwnPropertyDescriptor","prototype","formMember","form","get","call","e","callFormMethod","value","apply","Array","slice","arguments","tagName","el","toLowerCase","isElement","node","assertRealParent","parentNode","Error","closestByTag","names","indexOf","storeKey","setExpando","ignore","expando","els","namedItem","undefined","record","x","y","jQuery","data","type","setTimeout","captureSubmitter","target","point","offsetX","offsetY","fn","offset","pageX","left","pageY","top","offsetLeft","offsetTop","imagePoint","submitterOf","stored","log","ajaxSubmit","debug","msg","join","console","opera","postError","warned","deprecate","id","message","warn","deprecateOldJQuery","version","parts","String","split","major","Number","beforeJQuery35","shorthandOptions","options","dataType","onSuccess","result","url","success","submitOptions","key","hasOwnProperty","withoutUrl","keepContext","settings","sources","context","submitWith","isDefaultPrevented","preventDefault","originalEvent","submitter","captureEventSubmitter","doAjaxSubmit","captureSubmittingElement","this","bindDelegated","$sel","selector","off","on","closestMatch","Element","closest","is","delegated","unbindSelector","handlers","submit","click","selectionOnly","ajaxForm","jquery","delegation","bindSelector","beforeFormUnbind","ajaxFormUnbind","o","s","c","isReady","bindLater","formAttribute","attr","rLineBreak","rCR","rUnsubmittable","isDisabled","matches","disabled","valueOf","index","selectedIndex","a","ops","one","max","op","selected","v","attributes","specified","text","push","selectValue","val","raw","replace","urlencodedFields","fields","map","field","createSuccessfulControls","feature","$","controlsOf","semantic","formId","getElementsByTagName","makeArray","grep","ownedBy","test","navigator","userAgent","concat","filter","getAttribute","inArray","outsideControls","fieldsOf","n","fieldValue","constructor","fileapi","files","file","required","imageFields","sub","input","addCandidate","collected","own","controls","collect","filtering","addClickedImage","deepSerialize","extraData","traditional","part","param","serialized","len","decodeURIComponent","sendFormData","submission","formdata","FormData","append","serializedData","extend","ajaxSettings","contentType","processData","cache","method","uploadProgress","createXhr","xhr","upload","addEventListener","event","percent","position","loaded","total","lengthComputable","Math","ceil","beforeSend","formData","ajax","sendAjax","uploadAttributes","hasOwn","isGet","addSubmitterFields","submitterFields","addCsrfField","forms","origin","csrf_token","csrf_param","posts","property","href","location","protocol","host","setFormAttribute","getDoc","frame","doc","contentWindow","err","contentDocument","readStatus","status","statusText","readResponse","retry","errMsg","isXml","XMLDocument","isXMLDoc","body","innerHTML","docRoot","documentElement","responseText","responseXML","getResponseHeader","header","readDocument","dt","scr","textarea","ta","pre","b","textContent","innerText","readEmbedded","ct","xml","nodeName","error","dataFilter","JSON","parse","globalEval","httpData","createLifecycle","g","timeoutHandle","callbackProcessed","deferred","Deferred","aborted","getAllResponseHeaders","setRequestHeader","abort","done","rejection","textStatus","stop","reject","trigger","complete","endGlobalEvents","active","clearTimeout","release","settle","failure","resolve","succeed","start","global","fail","startTimer","onTimeout","timeout","stopTimer","createIframeTransport","hasProp","frameCount","fileUploadIframe","ownerDocument","$body","$io","iframeTarget","each","nameWindow","io","setAttribute","iframeSrc","css","createFrame","Date","getTime","life","execCommand","remove","frameHooks","domCheckCount","checkState","state","readyState","cb","doSubmit","saved","saveAttributes","mp","skipEncodingOverride","setUploadAttributes","extraInputs","added","addHiddenInput","appendTo","isPlainObject","single","f","addExtraInputs","root","contains","notInDocument","attachEvent","listen","submitForm","restoreAttributes","detachEvent","removeEventListener","unlisten","post","forceSync","jqxhr","elements","prop","removeAttr","enableControls","closeKeepAlive","createSubmission","serialization","refuse","extraQuery","optionsData","requestFormat","query","pairs","at","decodeQuery","queryPairs","defineKey","object","defineProperty","enumerable","writable","configurable","callbackList","callback","isArray","callEach","callbacks","args","prepare","$set","action","trim","URL","withDefaults","defaultType","veto","beforeSerialize","qx","beforeSubmit","resolved","resolveMethod","extra","stringify","jsonBody","q","toUpperCase","hashAt","base","encode","$form","deliver","resetForm","clearForm","includeHidden","successes","jqXHR","successArguments","replaceTarget","$target","merge","errors","completes","chooseTransport","hasFileInputs","add","multipart","attribute","fileAPI","shouldUseFrame","transport","iframe","steps","transports","attr2","removeData","k","formToArray","formSerialize","fieldSerialize","successful","t","checked","isSuccessful","clearFields","clearInputs","re","tag","replaceWith","clone","defaultChecked","defaultValue","select","parents","multiple","defaultSelected","find","forEl","htmlFor","getElementById","enable","parent"],"mappings":";;;;;;;;;;;;;;;;;;;;;kRAMA,IAAIA,EAAS,CAAC,kBAAmB,cAAe,UAAW,QAGvDC,EAAYC,SAASC,cAAc,QAEvC,SAASC,EAAeC,GACtB,IAAK,IAAIC,EAAI,EAAGA,EAAIN,EAAOO,OAAQD,IAAK,CACtC,IAAIE,EAAQC,OAAOT,EAAOM,IACtBI,EAAaF,GAASG,OAAOC,yBAAyBJ,EAAMK,UAAWR,GAE3E,GAAIK,EACF,OAAOA,CAEX,CAEA,OAAO,IACT,CAOO,SAASI,EAAWC,EAAMV,GAC/B,IAAIK,EAAaN,EAAeC,GAEhC,IACE,OAAOK,EAAWM,IAAIC,KAAKF,EAC7B,CAAE,MAAOG,GACP,OAAOH,EAAKV,EACd,CACF,CAM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AAKgX,gBAErBpc,EAAGqc,KAAK,UAAU5C,YAGpBwC,EAAOxC,aAGF,EAET,IAAK,SAMH,OAJAzZ,EAAGqc,KAAK,UAAU5I,KAAK,WACrBrO,KAAK2C,SAAW3C,KAAKgX,eACvB,IAEO,EAET,IAAK,QAGH,IAAIE,EAAQlX,KAAKmX,SAAWnX,KAAKiO,cAAcmJ,eAAepX,KAAKmX,SAInE,OAFAvc,EAAGqc,KAAK,yBAAyB/B,IAAIgC,GAAO3S,OAAO,yBAAyB8P,aAErE,EAET,IAAK,OAIH,OAFAha,EAAe2F,KAAM,UAEd,EAET,QAGE,OAFApF,EAAGqc,KAAK,oCAAoC5C,aAErC,EAEb,EACF,EAKA1Q,EAAElH,GAAG4a,OAAS,SAAUrM,GAKtB,YAJiB,IAANA,IACTA,GAAI,GAGChL,KAAKqO,KAAK,WACfrO,KAAKkC,UAAY8I,CACnB,EACF,EAMArH,EAAElH,GAAGkG,SAAW,SAAUkU,GAKxB,YAJsB,IAAXA,IACTA,GAAS,GAGJ7W,KAAKqO,KAAK,WACf,IAAI6H,EAAIlW,KAAK9D,KAEb,GAAU,aAANga,GAA0B,UAANA,EACtBlW,KAAKmW,QAAUU,OACV,GAAsB,WAAlBlc,EAAQqF,MAAoB,CACrC,IAAIE,EAAOyD,EAAE3D,MAAMsX,OAAO,UAEtBT,GAAU3W,EAAK,IAAuB,eAAjBA,EAAK,GAAGhE,MAE/BgE,EAAK+W,KAAK,UAAUtU,UAAS,GAG/B3C,KAAK2C,SAAWkU,CAClB,CACF,EACF,EAGAlT,EAAElH,GAAGY,WAAWC,OAAQ,CACzB,CAlcD,CAkcGtB"} \ No newline at end of file +{"version":3,"file":"jquery.form.min.js","sources":["../src/form-members.js","../src/submitter.js","../src/diagnostics.js","../src/options.js","../src/ajax-form.js","../src/form-attributes.js","../src/successful-controls.js","../src/xhr-transport.js","../src/iframe-post.js","../src/iframe-response.js","../src/iframe-lifecycle.js","../src/iframe-transport.js","../src/submission.js","../src/jquery.form.js"],"sourcesContent":["// Form members: the properties and methods the plugin reads or calls on a form. A control named\n// like a member (elements, setAttribute) shadows that member on the form itself, so members are\n// read through the DOM prototypes, which a control cannot shadow.\n\n// The prototype chain of a form, nearest first. Looked up on every call: old browsers have no\n// DOM prototypes, and tests remove them.\nvar owners = [\"HTMLFormElement\", \"HTMLElement\", \"Element\", \"Node\"];\n\n// A form no control can shadow, for methods when the DOM has no prototypes to read them from.\nvar plainForm = document.createElement(\"form\");\n\nfunction findDescriptor(name) {\n for (var i = 0; i < owners.length; i++) {\n var owner = window[owners[i]];\n var descriptor = owner && Object.getOwnPropertyDescriptor(owner.prototype, name);\n\n if (descriptor) {\n return descriptor;\n }\n }\n\n return null;\n}\n\n/**\n * Reads a member of a form through its prototype getter.\n * Falls back to the plain property without DOM prototypes, or on an element the getter does not\n * accept (such as a fieldset for `elements`).\n */\nexport function formMember(form, name) {\n var descriptor = findDescriptor(name);\n\n try {\n return descriptor.get.call(form);\n } catch (e) {\n return form[name];\n }\n}\n\n/**\n * Calls a method of a form through its prototype, or through an unshadowed form without DOM\n * prototypes.\n */\nexport function callFormMethod(form, name) {\n var descriptor = findDescriptor(name);\n var method = descriptor ? descriptor.value : plainForm[name];\n\n return method.apply(form, Array.prototype.slice.call(arguments, 2));\n}\n\n// Nodes such as the document and text nodes have no tag name (#600).\nexport function tagName(el) {\n var name = formMember(el, \"tagName\");\n\n return typeof name === \"string\" ? name.toLowerCase() : \"\";\n}\n\n/**\n * Whether a control or option is disabled, also through a disabled fieldset or optgroup. Without\n * selector matching, only its own disabled property is read.\n */\nexport function isDisabled(el) {\n return typeof el.matches === \"function\" ? el.matches(\":disabled\") : !!el.disabled;\n}\n\n// Elements only: the subject of formToArray may also be the document or a plain object.\nexport function isElement(node) {\n return formMember(node, \"nodeType\") === 1;\n}\n\n// A control named parentNode makes every parentNode walk (jQuery's trigger and closest among\n// them) cycle between the form and the control.\nexport function assertRealParent(el) {\n if (el.parentNode !== formMember(el, \"parentNode\")) {\n throw new Error(\n 'jquery.form: a form control named \"parentNode\" hides the form\\'s parentNode; rename the control'\n );\n }\n}\n\n// The element itself or its nearest ancestor with one of the tag names, through the real tree.\nexport function closestByTag(el, names) {\n for (var node = el; node; node = formMember(node, \"parentNode\")) {\n if (names.indexOf(tagName(node)) >= 0) {\n return node;\n }\n }\n\n return null;\n}\n","import { closestByTag, formMember, isDisabled } from \"./form-members.js\";\nimport jQuery from \"jquery\";\n\n// The submitter: the button that submitted a form, captured from ajaxForm's clicks. It is kept in\n// a private store and cleared shortly after the click. The form's clk, clk_x and clk_y properties\n// are still written for pages that read them, and read when the store has none.\n\nvar storeKey = \"jqFormSubmitter\";\n\n// Writes a property on the form; a control with that name makes it read-only.\nfunction setExpando(form, name, value) {\n try {\n form[name] = value;\n } catch (ignore) {\n // the control keeps the name; the store has the submitter\n }\n}\n\n// A property the page set on the form, never a control of the form with that name.\nfunction expando(form, name) {\n var value = form[name];\n var els = formMember(form, \"elements\");\n\n return els && value && els.namedItem(name) === value ? undefined : value;\n}\n\n// Records a submitter for a form until the click window ends.\nfunction record(form, el, x, y) {\n jQuery.data(form, storeKey, { el: el, x: x, y: y });\n setExpando(form, \"clk\", el);\n\n if (el.type === \"image\") {\n setExpando(form, \"clk_x\", x);\n setExpando(form, \"clk_y\", y);\n }\n\n // clear form vars\n setTimeout(function () {\n jQuery.data(form, storeKey, null);\n setExpando(form, \"clk\", null);\n setExpando(form, \"clk_x\", null);\n setExpando(form, \"clk_y\", null);\n }, 100);\n}\n\n// The clicked point of an image button, relative to the image.\nfunction imagePoint(e, target) {\n if (typeof e.offsetX !== \"undefined\") {\n return [e.offsetX, e.offsetY];\n }\n\n if (typeof jQuery.fn.offset === \"function\") {\n var offset = jQuery(target).offset();\n\n return [e.pageX - offset.left, e.pageY - offset.top];\n }\n\n return [e.pageX - target.offsetLeft, e.pageY - target.offsetTop];\n}\n\n/**\n * Records the submit or image button a click event reached, for the form it belongs to.\n */\nexport function captureSubmitter(e) {\n // the clicked control, or the button around the clicked content (ex: a span within a button)\n var target = closestByTag(e.target, [\"button\", \"input\"]);\n\n // the type property, unlike the attribute, is \"submit\" for a button without a type (#588)\n if (!target || (target.type !== \"submit\" && target.type !== \"image\")) {\n return;\n }\n\n var form = target.form;\n\n if (!form) {\n // a submit control that belongs to no form\n return;\n }\n\n var point = target.type === \"image\" ? imagePoint(e, target) : [];\n\n record(form, target, point[0], point[1]);\n}\n\n/**\n * Records the submitter a submit event names (SubmitEvent.submitter), when no click was captured.\n * An image submitter gets the point 0,0, as native submission sends it without a click.\n */\nexport function captureEventSubmitter(e, form) {\n var el = e.originalEvent && e.originalEvent.submitter;\n\n if (el && !submitterOf(form)) {\n record(form, el, 0, 0);\n }\n}\n\n/**\n * The form's submitter as { el, x, y } (x and y for an image button), or null.\n */\nexport function submitterOf(form) {\n if (!form) {\n return null;\n }\n\n var stored = jQuery.data(form, storeKey);\n\n if (stored) {\n return stored;\n }\n\n var el = expando(form, \"clk\");\n\n return el ? { el: el, x: expando(form, \"clk_x\"), y: expando(form, \"clk_y\") } : null;\n}\n\n/**\n * The submitter's fields for a post that adds them itself (the iframe upload), as name → value.\n */\nexport function submitterFields(form) {\n var fields = {};\n var sub = submitterOf(form);\n var el = sub && sub.el;\n\n // a disabled button is not sent, also when a disabled fieldset disables it\n if (el && el.name && !isDisabled(el)) {\n fields[el.name] = el.value;\n if (el.type === \"image\") {\n fields[el.name + \".x\"] = sub.x;\n fields[el.name + \".y\"] = sub.y;\n }\n }\n\n return fields;\n}\n\n/**\n * The form's submitter element, or null.\n */\nexport function submitterElement(form) {\n var sub = submitterOf(form);\n\n return sub ? sub.el : null;\n}\n","import jQuery from \"jquery\";\n\n// Debug logging, switched on by $.fn.ajaxSubmit.debug. The flag is read on every call, so it can\n// be turned on after the plugin loads.\nexport function log() {\n if (!jQuery.fn.ajaxSubmit.debug) {\n return;\n }\n\n var msg = \"[jquery.form] \" + Array.prototype.join.call(arguments, \"\");\n\n if (window.console && window.console.log) {\n window.console.log(msg);\n } else if (window.opera && window.opera.postError) {\n window.opera.postError(msg);\n }\n}\n\nvar warned = {};\n\n/**\n * A deprecation warning: console.warn, only while debug is on, once per id per page. The message\n * names the replacement; the warning adds that the feature is removed in 5.0.\n */\nexport function deprecate(id, message) {\n if (!jQuery.fn.ajaxSubmit.debug || warned[id]) {\n return;\n }\n\n warned[id] = true;\n\n if (window.console && typeof window.console.warn === \"function\") {\n window.console.warn(\"[jquery.form] \" + message + \" (removed in 5.0)\");\n }\n}\n\n// Forgets which deprecations have warned (for tests).\nexport function resetDeprecations() {\n warned = {};\n}\n\n// True for a jQuery version string older than 3.5.\nexport function beforeJQuery35(version) {\n var parts = String(version).split(\".\");\n var major = Number(parts[0]);\n\n return major < 3 || (major === 3 && Number(parts[1]) < 5);\n}\n\n// 5.0 needs jQuery 3.5 or later: warned on the first ajaxSubmit or ajaxForm, given jQuery's version.\nexport function deprecateOldJQuery(version) {\n if (beforeJQuery35(version)) {\n deprecate(\n \"jquery\",\n \"support for jQuery \" + version + \" is deprecated, 5.0 needs jQuery 3.5 or later\"\n );\n }\n}\n","import jQuery from \"jquery\";\nimport { log } from \"./diagnostics.js\";\n\n// The arguments ajaxSubmit and ajaxForm accept in place of an options object.\n\n/**\n * Turns the (url, data, dataType, success) shorthand into options. A url of false is kept as\n * the url; anything else is returned as given.\n */\nexport function shorthandOptions(options, data, dataType, onSuccess) {\n if (typeof options !== \"string\" && options !== false) {\n return options;\n }\n\n var result = { url: options, data: data, dataType: dataType };\n\n if (typeof onSuccess === \"function\") {\n result.success = onSuccess;\n }\n\n return result;\n}\n\n// A copy of options without its url, so the form action is used.\nfunction withoutUrl(options) {\n var result = {};\n\n for (var key in options) {\n if (key !== \"url\" && Object.prototype.hasOwnProperty.call(options, key)) {\n result[key] = options[key];\n }\n }\n\n return result;\n}\n\n/**\n * The options ajaxSubmit starts from: a function is the success callback, the shorthand is\n * expanded, and no options at all is an empty object. A url of false or \"\" means the form action.\n */\nexport function submitOptions(options, data, dataType, onSuccess) {\n if (typeof options === \"function\") {\n return { success: options };\n }\n\n options = shorthandOptions(options, data, dataType, onSuccess);\n\n if (typeof options === \"undefined\") {\n return {};\n }\n\n return options.url === false || options.url === \"\" ? withoutUrl(options) : options;\n}\n\n/**\n * jQuery treats `context` as a flat option: after a deep merge, the settings get back the\n * caller's own object from the last source that has one, so `this` in callbacks is that object.\n */\nexport function keepContext(settings, sources) {\n for (var i = 0; i < sources.length; i++) {\n if (sources[i].context !== undefined) {\n settings.context = sources[i].context;\n }\n }\n\n return settings;\n}\n\n/**\n * The elements a selector option (target, iframeTarget) names. A string is only ever a selector,\n * looked up in the document, so jQuery never builds elements from it; a string starting with \"<\"\n * is HTML, not a selector, and matches nothing. Elements and jQuery objects are used as given.\n */\nexport function selectorOption(value, ownerDocument) {\n if (typeof value !== \"string\") {\n return jQuery(value);\n }\n\n if (/^\\s*\"'\n );\n jQuery(function () {\n jQuery(o.s, o.c).ajaxForm(options);\n });\n\n return $sel;\n }\n\n // is your DOM ready? http://docs.jquery.com/Tutorials:Introducing_$(document).ready()\n log(\"terminating; zero elements found by selector\" + (jQuery.isReady ? \"\" : \" (DOM not ready)\"));\n\n return $sel;\n}\n\n// delegation: true on jQuery 3 and later, where the selection has no selector: always warned,\n// debug or not, once per ajaxForm call.\nfunction warnUnscoped() {\n var console = window.console || {};\n\n if (typeof console.warn === \"function\") {\n console.warn(\n \"[jquery.form] delegation: true binds every form on the page on jQuery 3 and later; \" +\n 'pass a selector instead, e.g. delegation: \"form.ajax\"'\n );\n }\n}\n\nfunction bindDelegated($sel, options) {\n if ($sel.selector === undefined) {\n warnUnscoped();\n }\n\n jQuery(document)\n .off(\"submit.form-plugin\", $sel.selector, doAjaxSubmit)\n .off(\"click.form-plugin\", $sel.selector, captureSubmittingElement)\n .on(\"submit.form-plugin\", $sel.selector, options, doAjaxSubmit)\n .on(\"click.form-plugin\", $sel.selector, options, captureSubmittingElement);\n\n return $sel;\n}\n\n// The element itself or its nearest ancestor that matches the selector. The walk never reads a\n// parentNode a control can hide (jQuery's delegated walk does, and cycles on such a form).\nfunction closestMatch(el, selector) {\n if (!isElement(el)) {\n return null;\n }\n\n if (window.Element && Element.prototype.closest) {\n return Element.prototype.closest.call(el, selector);\n }\n\n for (var node = el; node && isElement(node); node = formMember(node, \"parentNode\")) {\n if (jQuery(node).is(selector)) {\n return node;\n }\n }\n\n return null;\n}\n\n// The document handlers bound for each delegation selector, keyed by \"s\" + selector.\nvar delegated = {};\n\nfunction unbindSelector(selector) {\n var handlers = delegated[\"s\" + selector];\n\n if (handlers) {\n jQuery(document)\n .off(\"submit.form-plugin\", handlers.submit)\n .off(\"click.form-plugin\", handlers.click);\n delete delegated[\"s\" + selector];\n }\n}\n\n// delegation: \"\": one handler pair on the document, scoped to the selector.\nfunction bindSelector($sel, selector, options) {\n if (!selector) {\n throw new Error(\"jquery.form: delegation needs a selector, or true\");\n }\n\n var handlers = {\n submit: function (e) {\n if (closestMatch(e.target, selector)) {\n submitWith(e, options);\n }\n },\n click: function (e) {\n if (closestMatch(e.target, selector)) {\n captureSubmitter(e);\n }\n },\n };\n\n unbindSelector(selector);\n delegated[\"s\" + selector] = handlers;\n jQuery(document)\n .on(\"submit.form-plugin\", handlers.submit)\n .on(\"click.form-plugin\", handlers.click);\n\n return $sel;\n}\n\n// Passed by ajaxForm's own rebind: unbind the selection only, never the document handlers.\nvar selectionOnly = {};\n\n/**\n * ajaxForm() binds the selected forms so a submit is sent with ajaxSubmit, with the clicked\n * submit button (and image coordinates) included. The options work as for ajaxSubmit.\n */\nexport function ajaxForm(options, data, dataType, onSuccess) {\n deprecateOldJQuery(jQuery.fn.jquery);\n options = shorthandOptions(options, data, dataType, onSuccess) || {};\n\n if (typeof options.delegation === \"string\") {\n return bindSelector(this, options.delegation, options);\n }\n\n options.delegation = options.delegation && typeof jQuery.fn.on === \"function\";\n\n if (!options.delegation && this.length === 0) {\n return bindLater(this, options);\n }\n\n if (options.delegation) {\n return bindDelegated(this, options);\n }\n\n if (options.beforeFormUnbind) {\n options.beforeFormUnbind(this, options);\n }\n\n return this.ajaxFormUnbind(selectionOnly)\n .on(\"submit.form-plugin\", options, doAjaxSubmit)\n .on(\"click.form-plugin\", options, captureSubmittingElement);\n}\n\n/**\n * ajaxFormUnbind() removes the handlers ajaxForm bound on the selection and every delegated\n * binding on the document. ajaxFormUnbind(selector) removes only that delegation selector.\n */\nexport function ajaxFormUnbind(selector) {\n if (typeof selector === \"string\") {\n unbindSelector(selector);\n\n return this;\n }\n\n if (selector !== selectionOnly) {\n delegated = {};\n jQuery(document).off(\"submit.form-plugin click.form-plugin\");\n }\n\n return this.off(\"submit.form-plugin click.form-plugin\");\n}\n","import { callFormMethod, isElement } from \"./form-members.js\";\nimport jQuery from \"jquery\";\n\n/**\n * An attribute of a form, or undefined when it is absent, as jQuery's attr returns it. The\n * subject may also be the document or a plain object, read through jQuery.\n */\nexport function formAttribute(form, name) {\n if (!isElement(form)) {\n return jQuery(form).attr(name);\n }\n\n var value = callFormMethod(form, \"getAttribute\", name);\n\n return value === null ? undefined : value;\n}\n","import { callFormMethod, formMember, isDisabled, isElement, tagName } from \"./form-members.js\";\nimport { submitterElement, submitterOf } from \"./submitter.js\";\nimport { deprecate } from \"./diagnostics.js\";\nimport { formAttribute } from \"./form-attributes.js\";\nimport jQuery from \"jquery\";\n\n// Successful controls: which controls of a form are sent, and as which name/value fields\n// (https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#constructing-the-form-data-set).\n\n// Line breaks, sent as CRLF\nvar rLineBreak = /\\r\\n|\\r|\\n/g;\nvar rCR = /\\r/g;\n\n// Listed form elements that are never submitted.\nvar rUnsubmittable = /^(?:fieldset|object|output)$/;\n\n/**\n * The successful-control rule: whether a control is sent. `submitter` is the button that\n * submitted the control's form; other submit and image buttons of a form are not sent.\n */\nexport function isSuccessful(el, submitter) {\n var t = el.type;\n\n if (!el.name || isDisabled(el) || t === \"reset\" || t === \"button\") {\n return false;\n }\n\n if (t === \"checkbox\" || t === \"radio\") {\n return !!el.checked;\n }\n\n if (t === \"submit\" || t === \"image\") {\n return !el.form || submitter === el;\n }\n\n return tagName(el) !== \"select\" || el.selectedIndex !== -1;\n}\n\n// The value of a select: the selected option's value for one, a list for several.\nfunction selectValue(el) {\n var index = el.selectedIndex;\n\n if (index < 0) {\n return null;\n }\n\n var a = [],\n ops = el.options;\n var one = el.type === \"select-one\";\n var max = one ? index + 1 : ops.length;\n\n for (var i = one ? index : 0; i < max; i++) {\n var op = ops[i];\n\n if (op.selected && !isDisabled(op)) {\n var v = op.value;\n\n if (!v) {\n // extra pain for IE...\n v =\n op.attributes && op.attributes.value && !op.attributes.value.specified\n ? op.text\n : op.value;\n }\n\n if (one) {\n return v;\n }\n\n a.push(v);\n }\n }\n\n return a;\n}\n\n/**\n * The value of a control, whether or not it is successful: a list for a multiple select, null\n * for a select with nothing selected, otherwise a string with CRLF line breaks (a lone CR or LF\n * included).\n */\nexport function valueOf(el) {\n if (tagName(el) === \"select\") {\n return selectValue(el);\n }\n\n var v = jQuery(el).val();\n var raw = el.value;\n\n // jQuery before 4.0 drops carriage returns from .val(); read them from the value itself\n if (typeof raw === \"string\" && raw.replace(rCR, \"\") === v) {\n v = raw;\n }\n\n return v.replace(rLineBreak, \"\\r\\n\");\n}\n\n/**\n * The plugin's own $.fieldValue: the value of a control, or null when `successful` is true or\n * missing and the control is not sent.\n */\nexport function fieldValue(el, successful) {\n var required = typeof successful === \"undefined\" || successful;\n\n if (required && !isSuccessful(el, submitterElement(el.form))) {\n return null;\n }\n\n return valueOf(el);\n}\n\n// 5.0 serializes without $.fieldValue, so a page that replaces it is warned (under debug) when\n// formToArray, formSerialize, fieldSerialize or ajaxSubmit reads values through the replacement.\nexport function deprecateFieldValueOverride() {\n if (jQuery.fieldValue !== fieldValue) {\n deprecate(\n \"fieldValue-override\",\n \"replacing $.fieldValue to change what is serialized is deprecated, use jQuery valHooks\"\n );\n }\n}\n\n/**\n * The fields as a urlencoded body sends them: a selected file as its name.\n */\n// A lone surrogate becomes U+FFFD, as in a native submission; jQuery.param would throw.\nvar loneSurrogate = /[\\uD800-\\uDBFF](?![\\uDC00-\\uDFFF])|([^\\uD800-\\uDBFF]|^)([\\uDC00-\\uDFFF])/g;\n\nexport function wellFormed(value) {\n return typeof value === \"string\"\n ? value.replace(loneSurrogate, function (match, before) {\n return (before || \"\") + \"\\uFFFD\";\n })\n : value;\n}\n\n// Sets an own enumerable key, so a key like __proto__ stays an ordinary key.\nfunction setKey(object, key, value) {\n Object.defineProperty(object, key, {\n value: value,\n enumerable: true,\n writable: true,\n configurable: true,\n });\n}\n\n/**\n * Data for $.param (the data option or extraData) with lone surrogates in its keys and string\n * values made well formed. Arrays and objects are walked as $.param walks them, inherited keys\n * included; they are copied only when something changes.\n */\nexport function wellFormedData(data) {\n var isArray = Array.isArray(data);\n\n if (!isArray && Object.prototype.toString.call(data) !== \"[object Object]\") {\n return wellFormed(data);\n }\n\n var copy = isArray ? [] : {};\n var changed = false;\n\n if (isArray) {\n for (var i = 0; i < data.length; i++) {\n copy[i] = wellFormedData(data[i]);\n changed = changed || copy[i] !== data[i];\n }\n } else {\n for (var key in data) {\n var name = wellFormed(key);\n var value = wellFormedData(data[key]);\n\n changed = changed || name !== key || value !== data[key];\n setKey(copy, name, value);\n }\n }\n\n return changed ? copy : data;\n}\n\n// jQuery 3 dropped $.param's \"+\" for a space; a native submission still sends \"+\". Only a space\n// encodes as %20, since a literal % encodes as %25.\nexport function urlencode(fields, traditional) {\n return jQuery.param(urlencodedFields(fields), traditional).replace(/%20/g, \"+\");\n}\n\nexport function urlencodedFields(fields) {\n return jQuery.map(fields, function (field) {\n var value =\n field.type === \"file\" && typeof field.value !== \"string\" ? field.value.name : field.value;\n var name = wellFormed(field.name);\n value = wellFormed(value);\n\n return name === field.name && value === field.value ? field : { name: name, value: value };\n });\n}\n\n/**\n * The serialization steps. `feature` holds what the entry detected at load (fileapi).\n */\nexport function createSuccessfulControls(feature) {\n var $ = jQuery;\n\n // #386; inputs that name the form in their form attribute, other than the candidates found.\n // A form only gets the ones it owns.\n function outsideControls(formId, els, owner) {\n // hat tip @thet; the id is compared, never built into a selector\n return $(\":input[form]\")\n .filter(function () {\n return (\n this.getAttribute(\"form\") === formId &&\n (!owner || this.form === owner) &&\n $.inArray(this, els) < 0\n );\n })\n .get();\n }\n\n // A descendant of a form is a candidate unless it is a control another form owns.\n function ownedBy(els, owner) {\n return $.grep(els, function (el) {\n return typeof el.form === \"undefined\" || el.form === owner;\n });\n }\n\n /**\n * The candidate controls of a form, in order: its elements, or every descendant it owns in\n * semantic mode, then the outside controls it owns that name it.\n */\n function controlsOf(form, semantic) {\n var formId = formAttribute(form, \"id\");\n var els = formMember(form, \"elements\");\n\n if (semantic || typeof els === \"undefined\") {\n // the document is not an element; it has its own getElementsByTagName\n els = isElement(form)\n ? callFormMethod(form, \"getElementsByTagName\", \"*\")\n : form.getElementsByTagName(\"*\");\n }\n\n els = $.makeArray(els);\n\n // the subject may also be a fieldset, the document or another container\n var owner = tagName(form) === \"form\" ? form : null;\n\n if (semantic && owner) {\n els = ownedBy(els, owner);\n }\n\n // FinesseRus: in non-IE browsers outside fields are already included in form.elements.\n if (formId && (semantic || /(Edge|Trident)\\//.test(navigator.userAgent))) {\n els = els.concat(outsideControls(formId, els, owner));\n }\n\n return els;\n }\n\n // The fields of a control's value, or null when the control is not sent.\n function fieldsOf(el) {\n var n = el.name;\n // read at call time, so a page that replaces $.fieldValue changes what is sent\n var v = $.fieldValue(el, true);\n\n if (v && v.constructor === Array) {\n return $.map(v, function (value) {\n return { name: n, value: value };\n });\n }\n\n if (feature.fileapi && el.type === \"file\") {\n var files = el.files;\n\n // #180: an empty field when no file is selected\n return files.length\n ? $.map(files, function (file) {\n return { name: n, value: file, type: el.type };\n })\n : [{ name: n, value: \"\", type: el.type }];\n }\n\n if (v === null || typeof v === \"undefined\") {\n return null;\n }\n\n return [{ name: n, value: v, type: el.type, required: el.required }];\n }\n\n // The clicked image's value and coordinates.\n function imageFields(sub, input, type) {\n var n = input.name;\n var value = { name: n, value: $(input).val() };\n\n if (type) {\n value.type = type;\n }\n\n return [value, { name: n + \".x\", value: sub.x }, { name: n + \".y\", value: sub.y }];\n }\n\n // Adds one candidate control's fields, and the control when it has a value to send.\n function addCandidate(collected, form, el, semantic) {\n if (!el.name || isDisabled(el) || rUnsubmittable.test(tagName(el))) {\n return;\n }\n\n var sub = semantic && el.type === \"image\" && submitterOf(form);\n\n if (sub) {\n // handle image inputs on the fly when semantic == true\n if (sub.el === el) {\n collected.fields.push.apply(collected.fields, imageFields(sub, el, el.type));\n }\n\n return;\n }\n\n var own = fieldsOf(el);\n\n if (own) {\n collected.controls.push(el);\n collected.fields.push.apply(collected.fields, own);\n }\n }\n\n // input type=='image' are not found in elements array! handle it here\n function addClickedImage(collected, form) {\n var sub = submitterOf(form);\n var input = sub && $(sub.el)[0];\n\n if (input && input.name && !isDisabled(input) && input.type === \"image\") {\n collected.fields.push.apply(collected.fields, imageFields(sub, input));\n }\n }\n\n /**\n * The fields of a form, as formToArray returns them, and the controls they came from.\n */\n function collect(form, semantic, filtering) {\n var collected = { fields: [], controls: [] };\n\n if (!form) {\n return collected;\n }\n\n deprecateFieldValueOverride();\n\n var els = controlsOf(form, semantic);\n\n if (typeof filtering === \"function\") {\n els = $.map(els, filtering);\n }\n\n for (var i = 0; i < els.length; i++) {\n addCandidate(collected, form, els[i], semantic);\n }\n\n if (!semantic) {\n addClickedImage(collected, form);\n }\n\n return collected;\n }\n\n return {\n controlsOf: controlsOf,\n fieldsOf: fieldsOf,\n collect: collect,\n };\n}\n","import jQuery from \"jquery\";\nimport { keepContext } from \"./options.js\";\nimport { wellFormedData } from \"./successful-controls.js\";\n\n// The XMLHttpRequest transports: $.ajax with the encoded fields, or FormData for file uploads.\nvar $ = jQuery;\n\n// utility fn for deep serialization: [name, value] pairs, as $.param encodes them\nexport function deepSerialize(extraData, traditional) {\n var param = $.param(wellFormedData(extraData), traditional);\n var serialized = param ? param.split(\"&\") : [];\n var len = serialized.length;\n var result = [];\n var i, part;\n\n for (i = 0; i < len; i++) {\n // #252; undo param space replacement\n serialized[i] = serialized[i].replace(/\\+/g, \" \");\n part = serialized[i].split(\"=\");\n // #278; use array instead of object storage, favoring array serializations\n result.push([decodeURIComponent(part[0]), decodeURIComponent(part[1])]);\n }\n\n return result;\n}\n\n/**\n * Posts the fields and extraData as FormData, for files with the File API.\n * XMLHttpRequest Level 2 file uploads (big hat tip to francois2metz)\n */\nexport function sendFormData(submission) {\n var options = submission.options;\n var a = submission.fields;\n\n var formdata = new FormData();\n\n for (var i = 0; i < a.length; i++) {\n formdata.append(a[i].name, a[i].value);\n }\n\n if (options.extraData) {\n var serializedData = deepSerialize(options.extraData, submission.traditional);\n\n for (i = 0; i < serializedData.length; i++) {\n formdata.append(serializedData[i][0], serializedData[i][1]);\n }\n }\n\n options.data = null;\n\n var s = $.extend(true, {}, $.ajaxSettings, options, {\n contentType: false,\n processData: false,\n cache: false,\n type: submission.method || \"POST\",\n });\n\n keepContext(s, [$.ajaxSettings, options]);\n\n if (options.uploadProgress) {\n // workaround because jqXHR does not expose upload property: wraps the xhr factory, the\n // caller's or jQuery's\n var createXhr = s.xhr;\n\n s.xhr = function () {\n var xhr = createXhr.call(this);\n\n if (xhr.upload) {\n xhr.upload.addEventListener(\n \"progress\",\n function (event) {\n var percent = 0;\n // event.position is the deprecated name, read only when loaded is missing\n var position = event.loaded !== undefined ? event.loaded : event.position;\n var total = event.total;\n\n if (event.lengthComputable) {\n percent = Math.ceil((position / total) * 100);\n }\n\n options.uploadProgress(event, position, total, percent);\n },\n false\n );\n }\n\n return xhr;\n };\n }\n\n s.data = null;\n\n var beforeSend = s.beforeSend;\n\n s.beforeSend = function (xhr, o) {\n // Send FormData() provided by user\n if (options.formData) {\n o.data = options.formData;\n } else {\n o.data = formdata;\n }\n\n // a veto (false) cancels the upload, as on the other transports\n return beforeSend ? beforeSend.call(this, xhr, o) : undefined;\n };\n\n return $.ajax(s);\n}\n\n/**\n * Sends the encoded fields with $.ajax.\n */\nexport function sendAjax(submission) {\n return $.ajax(submission.options);\n}\n","import { callFormMethod } from \"./form-members.js\";\nimport { deepSerialize } from \"./xhr-transport.js\";\nimport jQuery from \"jquery\";\nimport { submitterFields } from \"./submitter.js\";\nimport { wellFormed } from \"./successful-controls.js\";\n\n// The iframe form post: the extra fields (submitter, CSRF, data), the form attributes set while\n// posting and restored after, and the native submit.\nvar $ = jQuery;\n\n// The form attributes an iframe upload changes while it posts.\nvar uploadAttributes = [\"action\", \"target\", \"method\", \"enctype\", \"encoding\"];\n\n// Called through the prototype: an extraData key or a form field may be named hasOwnProperty.\nvar hasOwn = Object.prototype.hasOwnProperty;\n\nfunction isGet(method) {\n return /^get$/i.test(method);\n}\n\n// Resolves both URLs through anchors, as jQuery does for crossDomain, so IE's anchor quirks\n// apply to both sides of the comparison.\nfunction isSameOrigin(url) {\n var origin = document.createElement(\"a\");\n var target = document.createElement(\"a\");\n\n origin.href = window.location.href;\n target.href = url;\n // IE fills in the host of a relative URL only once the resolved href is assigned back\n target.href = target.href; // eslint-disable-line no-self-assign\n\n return origin.protocol + \"//\" + origin.host === target.protocol + \"//\" + target.host;\n}\n\n/** Adds the clicked submitter (and an image's coordinates) to s.extraData. */\nexport function addSubmitterFields(s, form) {\n // add submitting element to data if we know it\n var fields = submitterFields(form);\n\n for (var n in fields) {\n s.extraData = s.extraData || {};\n s.extraData[wellFormed(n)] = wellFormed(fields[n]);\n }\n}\n\n/** Adds the page's CSRF token to s.extraData when the form is posted to the page's origin. */\nexport function addCsrfField(s, form, method, forms) {\n // Rails CSRF hack (thanks to Yvan Barthelemy); like jquery-ujs, only for the page's origin and\n // only when the form is posted, since a get form would put the token in the url\n var csrf_token = $(\"meta[name=csrf-token]\").attr(\"content\");\n var csrf_param = $(\"meta[name=csrf-param]\").attr(\"content\");\n var posts =\n !isGet(method) &&\n (!method || /post/i.test(method) || /post/i.test(forms.property(form, \"method\")));\n\n if (csrf_param && csrf_token && posts && isSameOrigin(s.url)) {\n s.extraData = s.extraData || {};\n s.extraData[csrf_param] = csrf_token;\n }\n}\n\nfunction setFormAttribute(form, name, value) {\n callFormMethod(form, \"setAttribute\", name, value);\n}\n\n/** The raw attributes the upload changes, null when absent, to put back exactly (#380). */\nexport function saveAttributes(form) {\n var saved = {};\n\n $.each(uploadAttributes, function (i, name) {\n saved[name] = callFormMethod(form, \"hasAttribute\", name)\n ? callFormMethod(form, \"getAttribute\", name)\n : null;\n });\n\n return saved;\n}\n\n/** Puts back the attributes saveAttributes recorded, removing those that were absent. */\nexport function restoreAttributes(form, saved) {\n $.each(uploadAttributes, function (i, name) {\n if (saved[name] === null) {\n callFormMethod(form, \"removeAttribute\", name);\n } else {\n setFormAttribute(form, name, saved[name]);\n }\n });\n}\n\n/** Points the form at the frame `target` with the upload's url, method and encoding. */\nexport function setUploadAttributes(form, target, method, s, forms) {\n var mp = \"multipart/form-data\";\n\n // update form attrs in IE friendly way\n setFormAttribute(form, \"target\", target);\n if (!method || /post/i.test(method)) {\n setFormAttribute(form, \"method\", \"POST\");\n } else if (isGet(method) && !isGet(forms.property(form, \"method\"))) {\n // a form posts natively only with GET or POST; other verbs keep the form's own method\n setFormAttribute(form, \"method\", \"GET\");\n }\n setFormAttribute(form, \"action\", s.url);\n\n // ie borks in some cases when setting encoding\n if (!s.skipEncodingOverride && (!method || /post/i.test(method))) {\n setFormAttribute(form, \"encoding\", mp);\n setFormAttribute(form, \"enctype\", mp);\n }\n}\n\n/** Appends a hidden input per extraData field to the form; each input is pushed onto `added`. */\nexport function addExtraInputs(form, ownerDocument, extraData, traditional, added) {\n // Builds the input with DOM properties: a name is never parsed as HTML.\n function addHiddenInput(name, value) {\n var input = ownerDocument.createElement(\"input\");\n\n input.type = \"hidden\";\n input.name = name;\n added.push($(input).val(value).appendTo(form)[0]);\n }\n\n if (extraData) {\n for (var n in extraData) {\n if (hasOwn.call(extraData, n)) {\n // if using the $.param format that allows for multiple values with the same name\n if (\n $.isPlainObject(extraData[n]) &&\n hasOwn.call(extraData[n], \"name\") &&\n hasOwn.call(extraData[n], \"value\")\n ) {\n addHiddenInput(wellFormed(extraData[n].name), wellFormed(extraData[n].value));\n } else {\n // arrays and objects become one field per value, as $.param sends them (#597)\n var single = {};\n\n single[n] = extraData[n];\n var fields = deepSerialize(single, traditional);\n\n for (var f = 0; f < fields.length; f++) {\n addHiddenInput(fields[f][0], fields[f][1]);\n }\n }\n }\n }\n }\n}\n\n/** Submits the form natively, even when a control named submit hides the method. */\nexport function submitForm(form) {\n try {\n form.submit();\n } catch (err) {\n // just in case form has element with name/id of 'submit'\n callFormMethod(form, \"submit\");\n }\n}\n","import jQuery from \"jquery\";\nimport { log } from \"./diagnostics.js\";\n\n// The iframe response reader: turns the frame's document into the mock xhr's text, XML, status\n// and dataType, then parses it as $.ajax would (dataFilter, JSON, script).\nvar $ = jQuery;\n\n/** The frame's document, or null when the browser denies access to it. */\nexport function getDoc(frame) {\n /* it looks like contentWindow or contentDocument do not\n * carry the protocol property in ie8, when running under ssl\n * frame.document is the only valid response document, since\n * the protocol is know but not on the other two objects. strange?\n * \"Same origin policy\" http://en.wikipedia.org/wiki/Same_origin_policy\n */\n\n var doc = null;\n\n // IE8 cascading access check\n try {\n if (frame.contentWindow) {\n doc = frame.contentWindow.document;\n }\n } catch (err) {\n // IE8 access denied under ssl & missing protocol\n log(\"cannot get iframe.contentWindow document: \" + err);\n }\n\n if (doc) {\n // successful getting content\n return doc;\n }\n\n try {\n // simply checking may throw in ie8 under ssl or mismatched protocol\n doc = frame.contentDocument ? frame.contentDocument : frame.document;\n } catch (err) {\n // last attempt\n log(\"cannot get iframe.contentDocument: \" + err);\n doc = frame.document;\n }\n\n return doc;\n}\n\n/** Parses the response text or XML for the given (lowercase) dataType. */\nexport function httpData(xhr, type, s) {\n // mostly lifted from jq1.4.4\n\n var ct = xhr.getResponseHeader(\"content-type\") || \"\",\n xml = (type === \"xml\" || !type) && ct.indexOf(\"xml\") >= 0,\n data = xml ? xhr.responseXML : xhr.responseText;\n\n if (xml && data.documentElement.nodeName === \"parsererror\") {\n if ($.error) {\n $.error(\"parsererror\");\n }\n }\n if (s && s.dataFilter) {\n data = s.dataFilter(data, type);\n }\n if (typeof data === \"string\") {\n if ((type === \"json\" || !type) && ct.indexOf(\"json\") >= 0) {\n data = JSON.parse(data);\n } else if (type === \"script\") {\n $.globalEval(data);\n }\n }\n\n return data;\n}\n\n// Copies the status and statusText attributes of an element onto the mock xhr.\nfunction readStatus(xhr, el) {\n // support for XHR 'status' & 'statusText' emulation :\n xhr.status = Number(el.getAttribute(\"status\")) || xhr.status;\n xhr.statusText = el.getAttribute(\"statusText\") || xhr.statusText;\n}\n\n// Fills the mock xhr from the document itself.\nfunction readDocument(doc, xhr, s, isXml) {\n var docRoot = doc.body ? doc.body : doc.documentElement;\n\n xhr.responseText = docRoot ? docRoot.innerHTML : null;\n xhr.responseXML = doc.XMLDocument ? doc.XMLDocument : doc;\n if (isXml) {\n s.dataType = \"xml\";\n }\n xhr.getResponseHeader = function (header) {\n // the dataType in lowercase, as $.ajax reads it\n var headers = { \"content-type\": s.dataType && s.dataType.toLowerCase() };\n\n return headers[header.toLowerCase()];\n };\n if (docRoot) {\n readStatus(xhr, docRoot);\n }\n}\n\n// A response embedded in a textarea, or text wrapped in pre or body, replaces responseText.\nfunction readEmbedded(doc, xhr, dt, s) {\n var scr = /(json|script|text)/.test(dt);\n\n if (!scr && !s.textarea) {\n return;\n }\n // see if user embedded response in textarea\n var ta = doc.getElementsByTagName(\"textarea\")[0];\n\n if (ta) {\n xhr.responseText = ta.value;\n readStatus(xhr, ta);\n } else if (scr) {\n // account for browsers injecting pre around json response\n var pre = doc.getElementsByTagName(\"pre\")[0];\n var b = doc.getElementsByTagName(\"body\")[0];\n\n if (pre) {\n xhr.responseText = pre.textContent ? pre.textContent : pre.innerText;\n } else if (b) {\n xhr.responseText = b.textContent ? b.textContent : b.innerText;\n }\n }\n}\n\n/**\n * Reads and parses the response document into the mock xhr. Returns {status, data, errMsg}, or\n * null when `retry()` asks to read the document again later (Opera's untraversable DOM).\n */\nexport function readResponse(doc, xhr, s, retry) {\n var status = \"success\",\n data,\n errMsg;\n\n try {\n var isXml = /^xml$/i.test(s.dataType) || doc.XMLDocument || $.isXMLDoc(doc);\n\n log(\"isXml=\" + isXml);\n\n if (!isXml && window.opera && (doc.body === null || !doc.body.innerHTML)) {\n // in some browsers (Opera) the iframe DOM is not always traversable when\n // the onload callback fires, so we loop a bit to accommodate\n if (retry()) {\n return null;\n }\n // let this fall through because server response could be an empty document\n }\n\n readDocument(doc, xhr, s, isXml);\n\n var dt = (s.dataType || \"\").toLowerCase();\n\n readEmbedded(doc, xhr, dt, s);\n\n try {\n data = httpData(xhr, dt, s);\n } catch (err) {\n status = \"parsererror\";\n xhr.error = errMsg = err || status;\n }\n } catch (err) {\n log(\"error caught: \", err);\n status = \"error\";\n xhr.error = errMsg = err;\n }\n\n return { status: status, data: data, errMsg: errMsg };\n}\n","import jQuery from \"jquery\";\nimport { log } from \"./diagnostics.js\";\n\n// The iframe upload's lifecycle: the mock xhr and the Deferred, the global ajax events, the\n// beforeSend veto, the timeout, abort and settling.\nvar $ = jQuery;\n\n/**\n * Creates the lifecycle of one upload with the merged settings `s`. `frame.stop()` stops the\n * frame's load and `frame.release()` removes or resets the frame after the upload.\n */\nexport function createLifecycle(s, frame) {\n var g,\n timeoutHandle,\n callbackProcessed,\n deferred = $.Deferred();\n\n var xhr = {\n // mock object\n aborted: 0,\n responseText: null,\n responseXML: null,\n status: 0,\n statusText: \"n/a\",\n getAllResponseHeaders: function () {},\n getResponseHeader: function () {},\n setRequestHeader: function () {},\n abort: function (status) {\n abort(status, [xhr, \"aborted\", status]);\n },\n };\n\n // #341\n deferred.abort = function (status) {\n xhr.abort(status);\n };\n\n function done() {\n return xhr.aborted || callbackProcessed;\n }\n\n // Completes an aborted upload once and rejects the Deferred with `rejection`.\n // `textStatus` replaces the default \"timeout\"/\"aborted\" text status.\n function abort(status, rejection, textStatus) {\n var e = textStatus || (status === \"timeout\" ? \"timeout\" : \"aborted\");\n\n if (done()) {\n return;\n }\n\n log(\"aborting upload... \" + e);\n xhr.aborted = 1;\n frame.stop();\n xhr.error = e;\n if (s.error) {\n s.error.call(s.context, xhr, e, status);\n }\n deferred.reject.apply(deferred, rejection);\n\n if (g) {\n $.event.trigger(\"ajaxError\", [xhr, s, e]);\n }\n\n complete(e);\n }\n\n // The global events that end every upload, cancelled ones included.\n function endGlobalEvents() {\n if (g) {\n $.event.trigger(\"ajaxComplete\", [xhr, s]);\n }\n\n if (g && !--$.active) {\n $.event.trigger(\"ajaxStop\");\n }\n }\n\n // The steps every finished or aborted upload ends with, in $.ajax order.\n function complete(status) {\n if (s.complete) {\n s.complete.call(s.context, xhr, status);\n }\n\n endGlobalEvents();\n clearTimeout(timeoutHandle);\n\n // clean up\n setTimeout(function () {\n frame.release();\n xhr.responseXML = null;\n }, 100);\n }\n\n // A beforeSend veto ends the upload as $.ajax cancels a request: no callbacks, the global\n // events end with ajaxError \"canceled\".\n function cancel() {\n if (done()) {\n return;\n }\n\n callbackProcessed = true;\n deferred.reject();\n if (g) {\n $.event.trigger(\"ajaxError\", [xhr, s, \"canceled\"]);\n }\n endGlobalEvents();\n }\n\n // Fires the start events and beforeSend; false when the upload must not be posted.\n function start() {\n g = s.global;\n // trigger ajax global events so that activity/block indicators work like normal\n if (g && $.active++ === 0) {\n $.event.trigger(\"ajaxStart\");\n }\n\n if (s.beforeSend && s.beforeSend.call(s.context, xhr, s) === false) {\n cancel();\n\n return false;\n }\n\n if (xhr.aborted) {\n // abort() in beforeSend already completed the upload\n return false;\n }\n\n if (g) {\n $.event.trigger(\"ajaxSend\", [xhr, s]);\n }\n\n // an ajaxSend handler may abort too\n return !xhr.aborted;\n }\n\n // Resolves the upload; returns {error} when the success callback threw.\n function succeed(data) {\n var failure;\n\n try {\n s.success.call(s.context, data, \"success\", xhr);\n } catch (err) {\n failure = { error: err };\n }\n\n deferred.resolve(xhr.responseText, \"success\", xhr);\n\n if (g) {\n $.event.trigger(\"ajaxSuccess\", [xhr, s, data]);\n }\n\n return failure;\n }\n\n // Settles the upload with the response reader's {status, data, errMsg}.\n function settle(result) {\n var status = result.status,\n errMsg = result.errMsg;\n\n if (xhr.aborted) {\n // abort() completed the upload while its response was processed\n log(\"upload aborted\");\n\n return;\n }\n\n // an emulated HTTP error status wins with the statusText, as in $.ajax; a parse error is\n // kept otherwise\n if (xhr.status && !((xhr.status >= 200 && xhr.status < 300) || xhr.status === 304)) {\n if (status === \"parsererror\") {\n errMsg = undefined;\n }\n status = \"error\";\n }\n\n callbackProcessed = true;\n\n // ordering of these callbacks/triggers is odd, but that's how $.ajax does it\n if (status === \"success\") {\n var failure = succeed(result.data);\n\n complete(status);\n if (failure) {\n // the upload is settled; the success callback's exception still reaches the console\n throw failure.error;\n }\n\n return;\n }\n\n if (typeof errMsg === \"undefined\") {\n errMsg = xhr.statusText;\n }\n if (s.error) {\n s.error.call(s.context, xhr, status, errMsg);\n }\n deferred.reject(xhr, status, errMsg);\n if (g) {\n $.event.trigger(\"ajaxError\", [xhr, s, errMsg]);\n }\n\n complete(status);\n }\n\n return {\n xhr: xhr,\n deferred: deferred,\n start: start,\n done: done,\n abort: abort,\n settle: settle,\n // Settles an upload that failed with an exception (ignored once aborted).\n fail: function (err) {\n settle({ status: \"error\", errMsg: err });\n },\n // Runs `onTimeout` after s.timeout, when set.\n startTimer: function (onTimeout) {\n if (s.timeout) {\n timeoutHandle = setTimeout(onTimeout, s.timeout);\n }\n },\n stopTimer: function () {\n clearTimeout(timeoutHandle);\n timeoutHandle = undefined;\n },\n };\n}\n","import {\n addCsrfField,\n addExtraInputs,\n addSubmitterFields,\n restoreAttributes,\n saveAttributes,\n setUploadAttributes,\n submitForm,\n} from \"./iframe-post.js\";\nimport { closestByTag, formMember } from \"./form-members.js\";\nimport { deprecate, log } from \"./diagnostics.js\";\nimport { getDoc, readResponse } from \"./iframe-response.js\";\nimport { keepContext, selectorOption } from \"./options.js\";\nimport { createLifecycle } from \"./iframe-lifecycle.js\";\nimport jQuery from \"jquery\";\n\n// The iframe transport: posts the form itself into a hidden frame and reads the response from it,\n// for file uploads without the File API or when the iframe option asks for it.\nvar $ = jQuery;\n\n/**\n * The iframe send step. `hasProp` is what the entry detected at load; `forms.property` reads a\n * form property as attr2 does.\n */\nexport function createIframeTransport(hasProp, forms) {\n var CLIENT_TIMEOUT_ABORT = 1;\n var SERVER_ABORT = 2;\n // tells apart the frames of uploads that start in the same millisecond\n var frameCount = 0;\n\n // ensure that every serialized input is still enabled\n function enableControls(elements) {\n for (var i = 0; i < elements.length; i++) {\n var el = $(elements[i]);\n\n if (hasProp) {\n el.prop(\"disabled\", false);\n } else {\n el.removeAttr(\"disabled\");\n }\n }\n }\n\n // Names the frame's window, when the page may: a cross-origin or sandboxed frame refuses.\n function nameWindow(frame, name) {\n try {\n if (frame.contentWindow) {\n frame.contentWindow.name = name;\n }\n } catch (ignore) {}\n }\n\n // The frame the form posts into: the iframeTarget, named `id` when it has no name, or a new\n // hidden frame named `id`. Returns the frame and the name the form targets.\n function createFrame(s, id, ownerDocument) {\n var $io, n;\n\n if (s.iframeTarget) {\n $io = selectorOption(s.iframeTarget, ownerDocument);\n n = $io.attr(\"name\");\n if (!n) {\n $io.attr(\"name\", id);\n // a frame already in the page keeps the browsing context name it was inserted with\n $io.each(function () {\n nameWindow(this, id);\n });\n } else {\n id = n;\n }\n } else {\n var io = ownerDocument.createElement(\"iframe\");\n\n io.setAttribute(\"name\", id);\n io.setAttribute(\"src\", s.iframeSrc);\n $io = $(io);\n $io.css({ position: \"absolute\", top: \"-1000px\", left: \"-1000px\" });\n }\n\n return { $io: $io, id: id };\n }\n\n // The frame hooks the lifecycle calls: stop a load in progress, and release after the upload.\n function frameHooks(s, $io) {\n return {\n stop: function () {\n try {\n // #214, #257\n if ($io[0].contentWindow.document.execCommand) {\n $io[0].contentWindow.document.execCommand(\"Stop\");\n }\n } catch (ignore) {}\n\n $io.attr(\"src\", s.iframeSrc); // abort op in progress\n },\n release: function () {\n if (!s.iframeTarget) {\n $io.remove();\n } else {\n // adding else to clean up existing iframe response.\n $io.attr(\"src\", s.iframeSrc);\n }\n },\n };\n }\n\n function listen(io, cb) {\n if (io.attachEvent) {\n io.attachEvent(\"onload\", cb);\n } else {\n io.addEventListener(\"load\", cb, false);\n }\n }\n\n function unlisten(io, cb) {\n if (io.detachEvent) {\n io.detachEvent(\"onload\", cb);\n } else {\n io.removeEventListener(\"load\", cb, false);\n }\n }\n\n // private function for handling file uploads (hat tip to YAHOO!)\n function fileUploadIframe(submission) {\n var form = submission.form,\n method = submission.method;\n\n var s = keepContext($.extend(true, {}, $.ajaxSettings, submission.options), [\n $.ajaxSettings,\n submission.options,\n ]);\n\n s.context = s.context || s;\n var ownerDocument = formMember(form, \"ownerDocument\");\n var $body = $(closestByTag(form, [\"body\"]));\n var frame = createFrame(s, \"jqFormIO\" + new Date().getTime() + frameCount++, ownerDocument);\n var $io = frame.$io,\n io = $io[0];\n var life = createLifecycle(s, frameHooks(s, $io));\n var domCheckCount = 50;\n\n if (!life.start()) {\n return life.deferred;\n }\n\n addSubmitterFields(s, form);\n addCsrfField(s, form, method, forms);\n\n // look for server aborts\n function checkState() {\n try {\n var state = getDoc(io).readyState;\n\n log(\"state = \" + state);\n if (state && state.toLowerCase() === \"uninitialized\") {\n setTimeout(checkState, 50);\n }\n } catch (e) {\n log(\"Server abort: \", e, \" (\", e.name, \")\");\n cb(SERVER_ABORT);\n life.stopTimer();\n }\n }\n\n // take a breath so that pending repaints get some cpu time before the upload starts\n function doSubmit() {\n var saved = saveAttributes(form);\n\n setUploadAttributes(form, frame.id, method, s, forms);\n\n // support timout\n life.startTimer(function () {\n cb(CLIENT_TIMEOUT_ABORT);\n });\n\n // add \"extra\" data to form if provided in options\n var extraInputs = [];\n\n try {\n addExtraInputs(form, ownerDocument, s.extraData, submission.traditional, extraInputs);\n\n if (!s.iframeTarget) {\n // add iframe to doc and submit the form\n $io.appendTo($body);\n }\n\n // A connected form posting into a frame outside the document opens a new window.\n var root = ownerDocument.documentElement;\n\n if (io && $.contains(root, form) && !$.contains(root, io)) {\n var notInDocument = \"jquery.form: the upload frame is not in the document\";\n\n life.abort(notInDocument, [life.xhr, \"error\", notInDocument], \"error\");\n\n return;\n }\n\n listen(io, cb);\n setTimeout(checkState, 15);\n submitForm(form);\n } finally {\n // reset attrs and remove \"extra\" input elements\n restoreAttributes(form, saved);\n $(extraInputs).remove();\n }\n }\n\n // Reads the next document by Opera's rules: false once the retries are used up.\n function retry() {\n if (--domCheckCount) {\n log(\"requeing onLoad callback, DOM not available\");\n setTimeout(cb, 250);\n\n return true;\n }\n\n return false;\n }\n\n function cb(e) {\n if (life.done()) {\n return;\n }\n\n var doc = getDoc(io);\n\n if (!doc) {\n log(\"cannot access response document\");\n e = SERVER_ABORT;\n }\n if (e === CLIENT_TIMEOUT_ABORT) {\n life.abort(\"timeout\", [life.xhr, \"timeout\"]);\n\n return;\n }\n if (e === SERVER_ABORT) {\n life.abort(\"server abort\", [life.xhr, \"error\", \"server abort\"]);\n\n return;\n }\n\n if (doc.location.href === s.iframeSrc) {\n // response not received yet\n return;\n }\n\n unlisten(io, cb);\n\n var result = readResponse(doc, life.xhr, s, retry);\n\n if (result) {\n life.settle(result);\n }\n }\n\n // An exception while posting settles the upload with \"error\" and the exception.\n function post() {\n if (life.done()) {\n // aborted before the delayed post\n return;\n }\n\n try {\n doSubmit();\n } catch (err) {\n log(\"upload failed: \", err);\n life.fail(err);\n }\n }\n\n if (s.forceSync) {\n post();\n } else {\n setTimeout(post, 10); // this lets dom updates render\n }\n\n return life.deferred;\n }\n\n return function sendIframe(submission) {\n var jqxhr;\n\n // now, while the controls are still listed: ajaxSubmit clears the list when it returns,\n // before a closeKeepAlive request completes\n enableControls(submission.controls);\n\n // hack to fix Safari hang (thanks to Tim Molendijk for this)\n // see: http://groups.google.com/group/jquery-dev/browse_thread/thread/36395b7ab510dd5d\n if (submission.options.closeKeepAlive) {\n deprecate(\"closeKeepAlive\", \"closeKeepAlive works around a Safari 3/4 bug and is deprecated\");\n $.get(submission.options.closeKeepAlive, function () {\n jqxhr = fileUploadIframe(submission);\n });\n } else {\n jqxhr = fileUploadIframe(submission);\n }\n\n return jqxhr;\n };\n}\n","import { deprecate, log } from \"./diagnostics.js\";\nimport { keepContext, selectorOption } from \"./options.js\";\nimport { urlencode, wellFormedData } from \"./successful-controls.js\";\nimport { assertRealParent } from \"./form-members.js\";\nimport jQuery from \"jquery\";\n\n// A Submission is one ajaxSubmit call once its vetoes have passed:\n// { form, $form, fields, controls, options, method, traditional }. `options` is the object the\n// callbacks and events receive; later steps change it in place.\n\n/**\n * The submission steps. `feature` holds what the entry detected at load (fileapi, formdata), and\n * `forms` reads form attributes and attr2-style properties (attribute, property), and\n * `serialization` collects the form's fields and controls.\n */\nexport function createSubmission(feature, forms, serialization) {\n var $ = jQuery;\n\n function refuse(message) {\n log(message);\n\n return null;\n }\n\n // The options merged over the form's action, the method, and the ajax defaults.\n function withDefaults(form, options, method) {\n var action = options.url || forms.property(form, \"action\");\n var url = typeof action === \"string\" ? action.trim() : \"\";\n\n // clean url (don't include hash value); an action that is only a fragment means this page\n url = url.split(\"#\")[0] || window.location.href.split(\"#\")[0];\n // IE requires javascript:false in https, but this breaks chrome >83 and goes against spec.\n // Instead of using javascript:false always, let's only apply it for IE.\n var isMsie = /(MSIE|Trident)/.test(navigator.userAgent || \"\");\n var iframeSrc = isMsie && /^https/i.test(document.URL) ? \"javascript:false\" : \"about:blank\"; // eslint-disable-line no-script-url\n\n var merged = $.extend(\n true,\n {\n url: url,\n success: $.ajaxSettings.success,\n type: method || $.ajaxSettings.type,\n iframeSrc: iframeSrc,\n },\n options\n );\n\n return keepContext(merged, [options]);\n }\n\n /**\n * The one method every transport sends, read after the hooks: `method` wins over `type`, and\n * `type` is set to it. Undefined when only the ajax default applies, so each transport keeps\n * its own default.\n */\n function resolveMethod(options, defaultType) {\n var resolved = options.method || options.type;\n\n options.type = resolved;\n\n return resolved === defaultType && !options.method ? undefined : resolved;\n }\n\n // The data option, kept as extraData and encoded, or undefined without one.\n function extraQuery(fields, options, traditional) {\n if (!options.data) {\n return undefined;\n }\n\n var optionsData = typeof options.data === \"function\" ? options.data(fields) : options.data;\n\n if (typeof optionsData === \"string\") {\n if (options.requestFormat === \"json\") {\n throw new Error(\n 'jquery.form: requestFormat \"json\" needs object data; a string data option is a query string'\n );\n }\n\n // a query string: sent as-is when urlencoded, as its own fields otherwise\n options.extraData = queryPairs(optionsData);\n\n return optionsData;\n }\n\n options.extraData = optionsData;\n\n return $.param(wellFormedData(optionsData), traditional);\n }\n\n // Sets a key as an own data property, so a name like __proto__ is an ordinary key.\n function defineKey(object, key, value) {\n Object.defineProperty(object, key, {\n value: value,\n enumerable: true,\n writable: true,\n configurable: true,\n });\n }\n\n /**\n * requestFormat \"json\" (#545): the fields as an object (a repeated name gives an array), merged\n * with object data, sent as a JSON body. Based on the idea in PR #557 by zhangciwu.\n */\n function jsonBody(options, fields) {\n if (/^get$/i.test(options.type)) {\n throw new Error('jquery.form: requestFormat \"json\" needs a method with a body, such as POST');\n }\n\n var body = {};\n var own = Object.prototype.hasOwnProperty;\n\n for (var i = 0; i < fields.length; i++) {\n var name = fields[i].name;\n\n if (!own.call(body, name)) {\n defineKey(body, name, fields[i].value);\n } else if (Array.isArray(body[name])) {\n body[name].push(fields[i].value);\n } else {\n defineKey(body, name, [body[name], fields[i].value]);\n }\n }\n\n var extra = options.extraData;\n\n for (var key in extra) {\n if (own.call(extra, key)) {\n defineKey(body, key, extra[key]);\n }\n }\n\n options.data = JSON.stringify(body);\n options.contentType = \"application/json; charset=UTF-8\";\n }\n\n // The fields of a query string, as the { name, value } list $.param takes.\n function queryPairs(query) {\n var pairs = [];\n var parts = query.split(\"&\");\n\n for (var i = 0; i < parts.length; i++) {\n if (parts[i]) {\n var at = parts[i].indexOf(\"=\");\n var name = at < 0 ? parts[i] : parts[i].slice(0, at);\n var value = at < 0 ? \"\" : parts[i].slice(at + 1);\n\n pairs.push({ name: decodeQuery(name), value: decodeQuery(value) });\n }\n }\n\n return pairs;\n }\n\n function decodeQuery(text) {\n return decodeURIComponent(text.replace(/\\+/g, \" \"));\n }\n\n // Puts the encoded fields in the url for a get, and in the data otherwise.\n function encode(options, q, qx) {\n if (qx) {\n q = q ? q + \"&\" + qx : qx;\n }\n\n if (options.type.toUpperCase() === \"GET\") {\n // the query goes before any fragment in the url option\n var hashAt = options.url.indexOf(\"#\");\n var base = hashAt < 0 ? options.url : options.url.slice(0, hashAt);\n\n options.url =\n base + (base.indexOf(\"?\") >= 0 ? \"&\" : \"?\") + q + options.url.slice(base.length);\n options.data = null; // data is null for 'get'\n } else {\n options.data = q; // data is the query string for 'post'\n }\n }\n\n // A callback option as a list: an array as given, one function, or none.\n function callbackList(callback) {\n if (Array.isArray(callback)) {\n return callback;\n }\n\n return callback ? [callback] : [];\n }\n\n // Calls each callback in order with the same this and arguments.\n function callEach(callbacks, context, args) {\n for (var i = 0; i < callbacks.length; i++) {\n callbacks[i].apply(context, args);\n }\n }\n\n /**\n * Resolves the options, serializes the form, and runs the vetoes: the Submission, or null when\n * an event or callback stopped it.\n */\n function prepare($set, options) {\n $set.each(function () {\n assertRealParent(this);\n });\n\n var form = $set[0];\n var method = options.method || options.type || forms.property(form, \"method\");\n\n options = withDefaults(form, options, method);\n\n // the ajax default type, when neither the caller nor the form gave a method\n var defaultType = method ? undefined : options.type;\n\n // hook for manipulating the form data before it is extracted;\n // convenient for use with rich editors like tinyMCE or FCKEditor\n var veto = {};\n\n $set.trigger(\"form-pre-serialize\", [$set, options, veto]);\n if (veto.veto) {\n return refuse(\"ajaxSubmit: submit vetoed via form-pre-serialize trigger\");\n }\n\n // provide opportunity to alter form data before it is serialized\n if (options.beforeSerialize && options.beforeSerialize($set, options) === false) {\n return refuse(\"ajaxSubmit: submit aborted via beforeSerialize callback\");\n }\n\n var traditional = options.traditional;\n\n if (typeof traditional === \"undefined\") {\n traditional = $.ajaxSettings.traditional;\n }\n\n var collected = serialization.collect($set[0], options.semantic, options.filtering);\n var fields = collected.fields;\n var controls = collected.controls;\n var qx = extraQuery(fields, options, traditional);\n\n // give pre-submit callback an opportunity to abort the submit\n if (options.beforeSubmit && options.beforeSubmit(fields, $set, options) === false) {\n return refuse(\"ajaxSubmit: submit aborted via beforeSubmit callback\");\n }\n\n // fire vetoable 'validate' event\n $set.trigger(\"form-submit-validate\", [fields, $set, options, veto]);\n if (veto.veto) {\n return refuse(\"ajaxSubmit: submit vetoed via form-submit-validate trigger\");\n }\n\n method = resolveMethod(options, defaultType);\n\n if (options.requestFormat === \"json\") {\n jsonBody(options, fields);\n } else {\n encode(options, urlencode(fields, traditional), qx);\n }\n\n return {\n form: form,\n $form: $set,\n fields: fields,\n controls: controls,\n options: options,\n method: method,\n traditional: traditional,\n };\n }\n\n /**\n * Wraps success, error and complete (a function or an array of them, as $.ajax takes) so each\n * also receives the form, and adds the resetForm,\n * clearForm and target steps before the success callbacks.\n */\n function deliver(submission) {\n var $set = submission.$form;\n var options = submission.options;\n var callbacks = [];\n\n if (options.resetForm) {\n callbacks.push(function () {\n $set.resetForm();\n });\n }\n\n if (options.clearForm) {\n callbacks.push(function () {\n $set.clearForm(options.includeHidden);\n });\n }\n\n // perform a load on the target only if dataType is not provided\n if (!options.dataType && options.target) {\n var successes = callbackList(options.success);\n\n callbacks.push(function (data, textStatus, jqXHR) {\n var successArguments = arguments,\n fn = options.replaceTarget ? \"replaceWith\" : \"html\",\n $target = selectorOption(options.target);\n\n // Only a string response is inserted. jQuery has already parsed a JSON or XML response,\n // and inserting it would parse each of its strings as HTML.\n if (typeof data === \"string\") {\n $target[fn](data);\n } else {\n log(\"target: the response was parsed by jQuery, so it is not inserted\");\n }\n\n if (!$target.length) {\n // nothing to fill: success still runs once, with the normal context\n callEach(successes, this, successArguments);\n }\n\n $target.each(function () {\n callEach(successes, this, successArguments);\n });\n });\n } else {\n $.merge(callbacks, callbackList(options.success));\n }\n\n options.success = function (data, status, xhr) {\n // jQuery 1.4+ passes xhr as 3rd arg\n var context = options.context || this; // jQuery 1.4+ supports scope context\n\n for (var i = 0, max = callbacks.length; i < max; i++) {\n callbacks[i].apply(context, [data, status, xhr || $set, $set]);\n }\n };\n\n if (options.error) {\n var errors = callbackList(options.error);\n\n options.error = function (xhr, status, error) {\n callEach(errors, options.context || this, [xhr, status, error, $set]);\n };\n }\n\n if (options.complete) {\n var completes = callbackList(options.complete);\n\n options.complete = function (xhr, status) {\n callEach(completes, options.context || this, [xhr, status, $set]);\n };\n }\n }\n\n /**\n * The transport for a submission: \"iframe\" for files without the File API or when forced,\n * \"formdata\" for files with it, \"ajax\" otherwise.\n */\n function chooseTransport(submission) {\n var $set = submission.$form;\n var options = submission.options;\n\n // [value] (issue #113), also see comment:\n // https://github.com/malsup/form/commit/588306aedba1de01388032d5f42a60159eea9228#commitcomment-2180219\n // and the file inputs outside the form that belong to it through their form attribute\n var fileInputs = $(\"input[type=file]:enabled\", $set)\n .add($(submission.controls).filter(\"input[type=file]\"))\n .filter(function () {\n return $(this).val() !== \"\";\n });\n var hasFileInputs = fileInputs.length > 0;\n // compared as the browser does: ASCII case-insensitive, without surrounding whitespace\n var mp = /^[\\t\\n\\f\\r ]*multipart\\/form-data[\\t\\n\\f\\r ]*$/i;\n var multipart =\n mp.test(forms.attribute($set[0], \"enctype\")) || mp.test(forms.attribute($set[0], \"encoding\"));\n var fileAPI = feature.fileapi && feature.formdata;\n\n log(\"fileAPI :\" + fileAPI);\n\n var shouldUseFrame = (hasFileInputs || multipart) && !fileAPI;\n\n var transport = (hasFileInputs || multipart) && fileAPI ? \"formdata\" : \"ajax\";\n\n // options.iframe allows user to force iframe mode\n // 06-NOV-09: now defaulting to iframe mode if file input is detected\n if (options.iframe !== false && (options.iframe || shouldUseFrame)) {\n transport = \"iframe\";\n }\n\n if (transport === \"iframe\" && !options.iframe) {\n deprecate(\n \"iframe\",\n \"choosing the iframe transport automatically without FormData is deprecated, set iframe: true\"\n );\n }\n\n if (transport !== \"ajax\" && options.requestFormat === \"json\") {\n throw new Error(\n 'jquery.form: requestFormat \"json\" cannot send files or use the iframe transport'\n );\n }\n\n return transport;\n }\n\n return { prepare: prepare, deliver: deliver, chooseTransport: chooseTransport };\n}\n","/*!\n * jQuery Form Plugin\n * version: 4.6.0\n * Requires jQuery v1.7.2 or later\n * Project repository: https://github.com/jquery-form/form\n\n * Copyright 2017 Kevin Morris\n * Copyright 2006 M. Alsup\n\n * Dual licensed under the LGPL-2.1+ or MIT licenses\n * https://github.com/jquery-form/form#license\n\n * This library is free software; you can redistribute it and/or\n * modify it under the terms of the GNU Lesser General Public\n * License as published by the Free Software Foundation; either\n * version 2.1 of the License, or (at your option) any later version.\n * This library is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * Lesser General Public License for more details.\n */\nimport { ajaxForm, ajaxFormUnbind } from \"./ajax-form.js\";\nimport { callFormMethod, tagName } from \"./form-members.js\";\nimport {\n createSuccessfulControls,\n deprecateFieldValueOverride,\n fieldValue,\n urlencode,\n} from \"./successful-controls.js\";\nimport { deprecate, deprecateOldJQuery, log } from \"./diagnostics.js\";\nimport { sendAjax, sendFormData } from \"./xhr-transport.js\";\nimport { createIframeTransport } from \"./iframe-transport.js\";\nimport { createSubmission } from \"./submission.js\";\nimport { formAttribute } from \"./form-attributes.js\";\nimport jQuery from \"jquery\";\nimport { submitOptions } from \"./options.js\";\n\n(function ($) {\n \"use strict\";\n\n /*\n\t\tUsage Note:\n\t\t-----------\n\t\tDo not use both ajaxSubmit and ajaxForm on the same form. These\n\t\tfunctions are mutually exclusive. Use ajaxSubmit if you want\n\t\tto bind your own submit handler to the form. For example,\n\n\t\t$(document).ready(function() {\n\t\t\t$('#myForm').on('submit', function(e) {\n\t\t\t\te.preventDefault(); // <-- important\n\t\t\t\t$(this).ajaxSubmit({\n\t\t\t\t\ttarget: '#output'\n\t\t\t\t});\n\t\t\t});\n\t\t});\n\n\t\tUse ajaxForm when you want the plugin to manage all the event binding\n\t\tfor you. For example,\n\n\t\t$(document).ready(function() {\n\t\t\t$('#myForm').ajaxForm({\n\t\t\t\ttarget: '#output'\n\t\t\t});\n\t\t});\n\n\t\tYou can also use ajaxForm with delegation (requires jQuery v1.7+), so the\n\t\tform does not have to exist when you invoke ajaxForm:\n\n\t\t$('#myForm').ajaxForm({\n\t\t\tdelegation: true,\n\t\t\ttarget: '#output'\n\t\t});\n\n\t\tWhen using ajaxForm, the ajaxSubmit function will be invoked for you\n\t\tat the appropriate time.\n\t*/\n\n /**\n * Feature detection\n */\n var feature = {};\n\n feature.fileapi = $('').get(0).files !== undefined;\n feature.formdata = typeof window.FormData !== \"undefined\";\n\n var hasProp = !!$.fn.prop;\n // What attr2 returns for a form: the property when it is a string, otherwise the attribute. The\n // property is read plainly on purpose: a control named like it shadows it, and then the raw\n // attribute is used.\n function formProperty(form, name) {\n var value = hasProp ? form[name] : undefined;\n\n return typeof value === \"string\" ? value : formAttribute(form, name);\n }\n\n var forms = { attribute: formAttribute, property: formProperty };\n var serialization = createSuccessfulControls(feature);\n var steps = createSubmission(feature, forms, serialization);\n var transports = {\n iframe: createIframeTransport(hasProp, forms),\n formdata: sendFormData,\n ajax: sendAjax,\n };\n\n // attr2 uses prop when it can but checks the return type for\n // an expected string. This accounts for the case where a form\n // contains inputs with names like \"action\" or \"method\"; in those\n // cases \"prop\" returns the element\n $.fn.attr2 = function () {\n deprecate(\"attr2\", \"attr2 is deprecated, use .prop() or .attr()\");\n\n if (!hasProp) {\n return this.attr.apply(this, arguments);\n }\n\n var val = this.prop.apply(this, arguments);\n\n if ((val && val.jquery) || typeof val === \"string\") {\n return val;\n }\n\n return this.attr.apply(this, arguments);\n };\n\n /**\n * ajaxSubmit() provides a mechanism for immediately submitting\n * an HTML form using AJAX.\n *\n * @param\t{object|string}\toptions\t\tjquery.form.js parameters or custom url for submission\n * @param\t{object}\t\tdata\t\textraData\n * @param\t{string}\t\tdataType\tajax dataType\n * @param\t{function}\t\tonSuccess\tajax success callback function\n */\n $.fn.ajaxSubmit = function (options, data, dataType, onSuccess) {\n deprecateOldJQuery($.fn.jquery);\n\n // fast fail if nothing selected (http://dev.jquery.com/ticket/2752)\n if (!this.length) {\n log(\"ajaxSubmit: skipping submit process - no element selected\");\n\n return this;\n }\n\n // #541: jQuery's slim build has no $.ajax\n if (!$.ajax) {\n throw new Error(\n \"jquery.form: ajaxSubmit needs the full jQuery build; this jQuery has no $.ajax\"\n );\n }\n\n var submission = steps.prepare(this, submitOptions(options, data, dataType, onSuccess));\n\n if (!submission) {\n return this;\n }\n\n steps.deliver(submission);\n\n var jqxhr = transports[steps.chooseTransport(submission)](submission);\n\n this.removeData(\"jqxhr\").data(\"jqxhr\", jqxhr);\n\n // clear element array\n for (var k = 0; k < submission.controls.length; k++) {\n submission.controls[k] = null;\n }\n\n // fire 'notify' event\n this.trigger(\"form-submit-notify\", [this, submission.options]);\n\n return this;\n };\n\n $.fn.ajaxForm = ajaxForm;\n $.fn.ajaxFormUnbind = ajaxFormUnbind;\n\n /**\n * formToArray() gathers form element data into an array of objects that can\n * be passed to any of the following ajax functions: $.get, $.post, or load.\n * Each object in the array has both a 'name' and 'value' property. An example of\n * an array for a simple login form might be:\n *\n * [ { name: 'username', value: 'jresig' }, { name: 'password', value: 'secret' } ]\n *\n * It is this array that is passed to pre-submit callback functions provided to the\n * ajaxSubmit() and ajaxForm() methods.\n */\n $.fn.formToArray = function (semantic, elements, filtering) {\n var collected = serialization.collect(this[0], semantic, filtering);\n\n if (elements) {\n elements.push.apply(elements, collected.controls);\n }\n\n return collected.fields;\n };\n\n /**\n * Serializes form data into a 'submittable' string. This method will return a string\n * in the format: name1=value1&name2=value2\n */\n $.fn.formSerialize = function (semantic) {\n // hand off to jQuery.param for proper encoding\n return urlencode(this.formToArray(semantic));\n };\n\n /**\n * Serializes all field elements in the jQuery object into a query string.\n * This method will return a string in the format: name1=value1&name2=value2\n */\n $.fn.fieldSerialize = function (successful) {\n var a = [];\n\n deprecateFieldValueOverride();\n\n this.each(function () {\n var n = this.name;\n\n // a form is not a field, though it may have a name\n if (!n || tagName(this) === \"form\") {\n return;\n }\n\n var v = $.fieldValue(this, successful);\n\n if (v && v.constructor === Array) {\n for (var i = 0, max = v.length; i < max; i++) {\n a.push({ name: n, value: v[i] });\n }\n } else if (v !== null && typeof v !== \"undefined\") {\n a.push({ name: this.name, value: v });\n }\n });\n\n // hand off to jQuery.param for proper encoding\n return urlencode(a);\n };\n\n /**\n * Returns the value(s) of the element in the matched set. For example, consider the following form:\n *\n *\t
\n *\t\t\n *\t\t\n *\t\t\n *\t\t\n *\t\t\n *\t\t\n *\t
\n *\n *\tvar v = $('input[type=text]').fieldValue();\n *\t// if no values are entered into the text inputs\n *\tv === ['','']\n *\t// if values entered into the text inputs are 'foo' and 'bar'\n *\tv === ['foo','bar']\n *\n *\tvar v = $('input[type=checkbox]').fieldValue();\n *\t// if neither checkbox is checked\n *\tv === undefined\n *\t// if both checkboxes are checked\n *\tv === ['B1', 'B2']\n *\n *\tvar v = $('input[type=radio]').fieldValue();\n *\t// if neither radio is checked\n *\tv === undefined\n *\t// if first radio is checked\n *\tv === ['C1']\n *\n * The successful argument controls whether or not the field element must be 'successful'\n * (per http://www.w3.org/TR/html4/interact/forms.html#successful-controls).\n * The default value of the successful argument is true. If this value is false the value(s)\n * for each element is returned.\n *\n * Note: This method *always* returns an array. If no valid value can be determined the\n *\tarray will be empty, otherwise it will contain one or more values.\n */\n $.fn.fieldValue = function (successful) {\n for (var val = [], i = 0, max = this.length; i < max; i++) {\n var el = this[i];\n var v = $.fieldValue(el, successful);\n\n if (v === null || typeof v === \"undefined\" || (v.constructor === Array && !v.length)) {\n continue;\n }\n\n if (v.constructor === Array) {\n $.merge(val, v);\n } else {\n val.push(v);\n }\n }\n\n return val;\n };\n\n /**\n * Returns the value of the field element.\n */\n $.fieldValue = fieldValue;\n\n /**\n * Clears the form data. Takes the following actions on the form's input fields:\n * - input text fields will have their 'value' property set to the empty string\n * - select elements will have their 'selectedIndex' property set to -1\n * - checkbox and radio inputs will have their 'checked' property set to false\n * - inputs of type submit, button, reset, and hidden will *not* be effected\n * - button elements will *not* be effected\n */\n $.fn.clearForm = function (includeHidden) {\n return this.each(function () {\n $(\"input,select,textarea\", this).clearFields(includeHidden);\n });\n };\n\n /**\n * Clears the selected form elements.\n */\n $.fn.clearInputs = function (includeHidden) {\n deprecate(\"clearInputs\", \"clearInputs is deprecated, use clearFields\");\n\n return this.clearFields(includeHidden);\n };\n\n $.fn.clearFields = function (includeHidden) {\n var re =\n /^(?:color|date|datetime|datetime-local|email|month|number|password|range|search|tel|text|time|url|week)$/i; // 'hidden' is not in this list\n\n return this.each(function () {\n var t = this.type,\n tag = tagName(this);\n\n if (re.test(t) || tag === \"textarea\") {\n this.value = \"\";\n } else if (t === \"checkbox\" || t === \"radio\") {\n this.checked = false;\n } else if (tag === \"select\") {\n this.selectedIndex = -1;\n } else if (t === \"file\") {\n if (/MSIE/.test(navigator.userAgent)) {\n $(this).replaceWith($(this).clone(true));\n } else {\n $(this).val(\"\");\n }\n } else if (includeHidden) {\n // includeHidden can be the value true, or it can be a selector string\n // indicating a special test; for example:\n // $('#myForm').clearForm('.special:hidden')\n // the above would clean hidden inputs that have the class of 'special'\n if (\n (includeHidden === true && /hidden/.test(t)) ||\n (typeof includeHidden === \"string\" && $(this).is(includeHidden))\n ) {\n this.value = \"\";\n }\n }\n });\n };\n\n /**\n * Resets the form data or individual elements. Takes the following actions\n * on the selected tags:\n * - all fields within form elements will be reset to their original value\n * - input / textarea / select fields will be reset to their original value\n * - option / optgroup fields (for multi-selects) will defaulted individually\n * - non-multiple options will find the right select to default\n * - label elements will be searched against its 'for' attribute\n * - all others will be searched for appropriate children to default\n */\n $.fn.resetForm = function () {\n return this.each(function () {\n var el = $(this);\n var tag = tagName(this);\n\n switch (tag) {\n case \"input\":\n this.checked = this.defaultChecked;\n\n // as the native reset: types whose value is the value attribute keep it\n if (this.type === \"file\") {\n // a file input cannot take its value attribute; the native reset empties it\n this.value = \"\";\n } else if (!/^(?:checkbox|radio|hidden|submit|reset|button|image)$/.test(this.type)) {\n this.value = this.defaultValue;\n }\n\n return true;\n\n case \"textarea\":\n this.value = this.defaultValue;\n\n return true;\n\n case \"option\":\n case \"optgroup\":\n var select = el.parents(\"select\");\n\n if (select.length && select[0].multiple) {\n if (tag === \"option\") {\n this.selected = this.defaultSelected;\n } else {\n el.find(\"option\").resetForm();\n }\n } else {\n select.resetForm();\n }\n\n return true;\n\n case \"select\":\n // in order, as the native reset: of several default options, a single select keeps the last\n el.find(\"option\").each(function () {\n this.selected = this.defaultSelected;\n });\n\n return true;\n\n case \"label\":\n // The control whose id the for attribute names, and the controls inside the label. The\n // filter keeps a for that names an ancestor from resetting the label again.\n var forEl = this.htmlFor && this.ownerDocument.getElementById(this.htmlFor);\n\n el.find(\"input,select,textarea\").add(forEl).filter(\"input,select,textarea\").resetForm();\n\n return true;\n\n case \"form\":\n // through the prototype: a control named reset shadows the method\n callFormMethod(this, \"reset\");\n\n return true;\n\n default:\n el.find(\"form,input,label,select,textarea\").resetForm();\n\n return true;\n }\n });\n };\n\n /**\n * Enables or disables any matching elements.\n */\n $.fn.enable = function (b) {\n if (typeof b === \"undefined\") {\n b = true;\n }\n\n return this.each(function () {\n this.disabled = !b;\n });\n };\n\n /**\n * Checks/unchecks any matching checkboxes or radio buttons and\n * selects/deselects and matching option elements.\n */\n $.fn.selected = function (select) {\n if (typeof select === \"undefined\") {\n select = true;\n }\n\n return this.each(function () {\n var t = this.type;\n\n if (t === \"checkbox\" || t === \"radio\") {\n this.checked = select;\n } else if (tagName(this) === \"option\") {\n var $sel = $(this).parent(\"select\");\n\n if (select && $sel[0] && $sel[0].type === \"select-one\") {\n // deselect all other options\n $sel.find(\"option\").selected(false);\n }\n\n this.selected = select;\n }\n });\n };\n\n // expose debug var\n $.fn.ajaxSubmit.debug = false;\n})(jQuery);\n\nexport default jQuery;\n"],"names":["owners","plainForm","document","createElement","findDescriptor","name","i","length","owner","window","descriptor","Object","getOwnPropertyDescriptor","prototype","formMember","form","get","call","e","callFormMethod","value","apply","Array","slice","arguments","tagName","el","toLowerCase","isDisabled","matches","disabled","isElement","node","assertRealParent","parentNode","Error","closestByTag","names","indexOf","storeKey","setExpando","ignore","expando","els","namedItem","undefined","record","x","y","jQuery","data","type","setTimeout","captureSubmitter","target","point","offsetX","offsetY","fn","offset","pageX","left","pageY","top","offsetLeft","offsetTop","imagePoint","submitterOf","stored","log","ajaxSubmit","debug","msg","join","console","opera","postError","warned","deprecate","id","message","warn","deprecateOldJQuery","version","parts","String","split","major","Number","beforeJQuery35","shorthandOptions","options","dataType","onSuccess","result","url","success","submitOptions","key","hasOwnProperty","withoutUrl","keepContext","settings","sources","context","selectorOption","ownerDocument","test","find","submitWith","isDefaultPrevented","preventDefault","originalEvent","submitter","captureEventSubmitter","doAjaxSubmit","captureSubmittingElement","this","bindDelegated","$sel","selector","off","on","closestMatch","Element","closest","is","delegated","unbindSelector","handlers","submit","click","selectionOnly","ajaxForm","jquery","delegation","bindSelector","beforeFormUnbind","ajaxFormUnbind","o","s","c","isReady","bindLater","formAttribute","attr","rLineBreak","rCR","rUnsubmittable","valueOf","index","selectedIndex","a","ops","one","max","op","selected","v","attributes","specified","text","push","selectValue","val","raw","replace","fieldValue","successful","sub","t","checked","isSuccessful","deprecateFieldValueOverride","loneSurrogate","wellFormed","match","before","setKey","object","defineProperty","enumerable","writable","configurable","wellFormedData","isArray","toString","copy","changed","urlencode","fields","traditional","param","map","field","urlencodedFields","createSuccessfulControls","feature","$","controlsOf","semantic","formId","getElementsByTagName","makeArray","grep","ownedBy","navigator","userAgent","concat","filter","getAttribute","inArray","outsideControls","fieldsOf","n","constructor","fileapi","files","file","required","imageFields","input","addCandidate","collected","own","controls","collect","filtering","addClickedImage","deepSerialize","extraData","part","serialized","len","decodeURIComponent","sendFormData","submission","formdata","FormData","append","serializedData","extend","ajaxSettings","contentType","processData","cache","method","uploadProgress","createXhr","xhr","upload","addEventListener","event","percent","position","loaded","total","lengthComputable","Math","ceil","beforeSend","formData","ajax","sendAjax","uploadAttributes","hasOwn","isGet","addSubmitterFields","submitterFields","addCsrfField","forms","origin","csrf_token","csrf_param","posts","property","href","location","protocol","host","setFormAttribute","getDoc","frame","doc","contentWindow","err","contentDocument","readStatus","status","statusText","readResponse","retry","errMsg","isXml","XMLDocument","isXMLDoc","body","innerHTML","docRoot","documentElement","responseText","responseXML","getResponseHeader","header","readDocument","dt","scr","textarea","ta","pre","b","textContent","innerText","readEmbedded","ct","xml","nodeName","error","dataFilter","JSON","parse","globalEval","httpData","createLifecycle","g","timeoutHandle","callbackProcessed","deferred","Deferred","aborted","getAllResponseHeaders","setRequestHeader","abort","done","rejection","textStatus","stop","reject","trigger","complete","endGlobalEvents","active","clearTimeout","release","settle","failure","resolve","succeed","start","global","fail","startTimer","onTimeout","timeout","stopTimer","createIframeTransport","hasProp","frameCount","fileUploadIframe","$body","$io","iframeTarget","each","nameWindow","io","setAttribute","iframeSrc","css","createFrame","Date","getTime","life","execCommand","remove","frameHooks","domCheckCount","checkState","state","readyState","cb","doSubmit","saved","saveAttributes","mp","skipEncodingOverride","setUploadAttributes","extraInputs","added","addHiddenInput","appendTo","isPlainObject","single","f","addExtraInputs","root","contains","notInDocument","attachEvent","listen","submitForm","restoreAttributes","detachEvent","removeEventListener","unlisten","post","forceSync","jqxhr","elements","prop","removeAttr","enableControls","closeKeepAlive","createSubmission","serialization","refuse","extraQuery","optionsData","requestFormat","query","pairs","at","decodeQuery","queryPairs","defineKey","callbackList","callback","callEach","callbacks","args","prepare","$set","action","trim","URL","withDefaults","defaultType","veto","beforeSerialize","qx","beforeSubmit","resolved","resolveMethod","extra","stringify","jsonBody","q","toUpperCase","hashAt","base","encode","$form","deliver","resetForm","clearForm","includeHidden","successes","jqXHR","successArguments","replaceTarget","$target","merge","errors","completes","chooseTransport","hasFileInputs","add","multipart","attribute","fileAPI","shouldUseFrame","transport","iframe","steps","transports","attr2","removeData","k","formToArray","formSerialize","fieldSerialize","clearFields","clearInputs","re","tag","replaceWith","clone","defaultChecked","defaultValue","select","parents","multiple","defaultSelected","forEl","htmlFor","getElementById","enable","parent"],"mappings":";;;;;;;;;;;;;;;;;;;;;4ZAMIA,EAAS,CAAC,kBAAmB,cAAe,UAAW,QAGvDC,EAAYC,EAASC,cAAc,QAEvC,SAASC,EAAeC,GACtB,IAAK,IAAIC,EAAI,EAAGA,EAAIN,EAAOO,OAAQD,IAAK,CACtC,IAAIE,EAAQC,EAAOT,EAAOM,IACtBI,EAAaF,GAASG,OAAOC,yBAAyBJ,EAAMK,UAAWR,GAE3E,GAAIK,EACF,OAAOA,CAEX,CAEA,OAAO,IACT,CAOO,SAASI,EAAWC,EAAMV,GAC/B,IAAIK,EAAaN,EAAeC,GAEhC,IACE,OAAOK,EAAWM,IAAIC,KAAKF,EAC7B,CAAE,MAAOG,GACP,OAAOH,EAAKV,EACd,CACF,CAMO,SAASc,EAAeJ,EAAMV,GACnC,IAAIK,EAAaN,EAAeC,GAGhC,OAFaK,EAAaA,EAAWU,MAAQnB,EAAUI,IAEzCgB,MAAMN,EAAMO,MAAMT,UAAUU,MAAMN,KAAKO,UAAW,GAClE,CAGO,SAASC,EAAQC,GACtB,IAAIrB,EAAOS,EAAWY,EAAI,WAE1B,MAAuB,iBAATrB,EAAoBA,EAAKsB,cAAgB,EACzD,CAMO,SAASC,EAAWF,GACzB,MAA6B,mBAAfA,EAAGG,QAAyBH,EAAGG,QAAQ,eAAiBH,EAAGI,QAC3E,CAGO,SAASC,EAAUC,GACxB,OAAwC,IAAjClB,EAAWkB,EAAM,WAC1B,CAIO,SAASC,EAAiBP,GAC/B,GAAIA,EAAGQ,aAAepB,EAAWY,EAAI,cACnC,MAAM,IAAIS,MACR,kGAGN,CAGO,SAASC,EAAaV,EAAIW,GAC/B,IAAK,IAAIL,EAAON,EAAIM,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,IAAI2B,GAAO3R,OAAO,yBAAyBmP,aAErE,EAET,IAAK,OAIH,OAFAjb,EAAekG,KAAM,UAEd,EAET,QAGE,OAFA3F,EAAGkF,KAAK,oCAAoCwV,aAErC,EAEb,EACF,EAKA9P,EAAE5I,GAAGqb,OAAS,SAAUzL,GAKtB,YAJiB,IAANA,IACTA,GAAI,GAGCjM,KAAKqP,KAAK,WACfrP,KAAKvF,UAAYwR,CACnB,EACF,EAMAhH,EAAE5I,GAAGmG,SAAW,SAAU2U,GAKxB,YAJsB,IAAXA,IACTA,GAAS,GAGJnX,KAAKqP,KAAK,WACf,IAAIhM,EAAIrD,KAAKlE,KAEb,GAAU,aAANuH,GAA0B,UAANA,EACtBrD,KAAKsD,QAAU6T,OACV,GAAsB,WAAlB/c,EAAQ4F,MAAoB,CACrC,IAAIE,EAAO+E,EAAEjF,MAAM2X,OAAO,UAEtBR,GAAUjX,EAAK,IAAuB,eAAjBA,EAAK,GAAGpE,MAE/BoE,EAAKX,KAAK,UAAUiD,UAAS,GAG/BxC,KAAKwC,SAAW2U,CAClB,CACF,EACF,EAGAlS,EAAE5I,GAAGY,WAAWC,OAAQ,CACzB,CA5bD,CA4bGtB"} \ No newline at end of file diff --git a/dist/jquery.form.mjs b/dist/jquery.form.mjs index 954b8743..faa9fab7 100644 --- a/dist/jquery.form.mjs +++ b/dist/jquery.form.mjs @@ -1,6 +1,6 @@ /*! * jQuery Form Plugin - * version: 4.5.0 + * version: 4.6.0 * Requires jQuery v1.7.2 or later * Project repository: https://github.com/jquery-form/form @@ -80,6 +80,14 @@ function tagName(el) { return typeof name === "string" ? name.toLowerCase() : ""; } +/** + * Whether a control or option is disabled, also through a disabled fieldset or optgroup. Without + * selector matching, only its own disabled property is read. + */ +function isDisabled(el) { + return typeof el.matches === "function" ? el.matches(":disabled") : !!el.disabled; +} + // Elements only: the subject of formToArray may also be the document or a plain object. function isElement(node) { return formMember(node, "nodeType") === 1; @@ -226,7 +234,8 @@ function submitterFields(form) { var sub = submitterOf(form); var el = sub && sub.el; - if (el && el.name && !el.disabled) { + // a disabled button is not sent, also when a disabled fieldset disables it + if (el && el.name && !isDisabled(el)) { fields[el.name] = el.value; if (el.type === "image") { fields[el.name + ".x"] = sub.x; @@ -363,6 +372,25 @@ function keepContext(settings, sources) { return settings; } +/** + * The elements a selector option (target, iframeTarget) names. A string is only ever a selector, + * looked up in the document, so jQuery never builds elements from it; a string starting with "<" + * is HTML, not a selector, and matches nothing. Elements and jQuery objects are used as given. + */ +function selectorOption(value, ownerDocument) { + if (typeof value !== "string") { + return jQuery(value); + } + + if (/^\s*= 200 && xhr.status < 300) || xhr.status === 304)) { + if (status === "parsererror") { + errMsg = undefined; + } status = "error"; } @@ -1469,7 +1583,7 @@ function createLifecycle(s, frame) { if (s.error) { s.error.call(s.context, xhr, status, errMsg); } - deferred.reject(xhr, "error", errMsg); + deferred.reject(xhr, status, errMsg); if (g) { $$1.event.trigger("ajaxError", [xhr, s, errMsg]); } @@ -1543,7 +1657,7 @@ function createIframeTransport(hasProp, forms) { var $io, n; if (s.iframeTarget) { - $io = $(s.iframeTarget, ownerDocument); + $io = selectorOption(s.iframeTarget, ownerDocument); n = $io.attr("name"); if (!n) { $io.attr("name", id); @@ -1865,7 +1979,7 @@ function createSubmission(feature, forms, serialization) { options.extraData = optionsData; - return $.param(optionsData, traditional); + return $.param(wellFormedData(optionsData), traditional); } // Sets a key as an own data property, so a name like __proto__ is an ordinary key. @@ -2029,7 +2143,7 @@ function createSubmission(feature, forms, serialization) { if (options.requestFormat === "json") { jsonBody(options, fields); } else { - encode(options, $.param(urlencodedFields(fields), traditional), qx); + encode(options, urlencode(fields, traditional), qx); } return { @@ -2072,7 +2186,7 @@ function createSubmission(feature, forms, serialization) { callbacks.push(function (data, textStatus, jqXHR) { var successArguments = arguments, fn = options.replaceTarget ? "replaceWith" : "html", - $target = $(options.target); + $target = selectorOption(options.target); // Only a string response is inserted. jQuery has already parsed a JSON or XML response, // and inserting it would parse each of its strings as HTML. @@ -2340,7 +2454,7 @@ function createSubmission(feature, forms, serialization) { */ $.fn.formSerialize = function (semantic) { // hand off to jQuery.param for proper encoding - return $.param(urlencodedFields(this.formToArray(semantic))); + return urlencode(this.formToArray(semantic)); }; /** @@ -2350,6 +2464,8 @@ function createSubmission(feature, forms, serialization) { $.fn.fieldSerialize = function (successful) { var a = []; + deprecateFieldValueOverride(); + this.each(function () { var n = this.name; @@ -2370,7 +2486,7 @@ function createSubmission(feature, forms, serialization) { }); // hand off to jQuery.param for proper encoding - return $.param(a); + return urlencode(a); }; /** @@ -2433,15 +2549,7 @@ function createSubmission(feature, forms, serialization) { /** * Returns the value of the field element. */ - $.fieldValue = function (el, successful) { - var required = typeof successful === "undefined" || successful; - - if (required && !isSuccessful(el, submitterElement(el.form))) { - return null; - } - - return valueOf(el); - }; + $.fieldValue = fieldValue; /** * Clears the form data. Takes the following actions on the form's input fields: diff --git a/docs/_layouts/default.html b/docs/_layouts/default.html index 66491228..ff20a20b 100644 --- a/docs/_layouts/default.html +++ b/docs/_layouts/default.html @@ -2,13 +2,9 @@ - - {{ site.title | default: site.github.repository_name }} by {{ site.github.owner_name }} @@ -58,16 +54,5 @@

{{ site.description | default: site.github.project_tagline }}

- - {% if site.google_analytics %} - - {% endif %} diff --git a/docs/api.md b/docs/api.md index 6dc90114..c334ca0e 100644 --- a/docs/api.md +++ b/docs/api.md @@ -7,7 +7,7 @@ The Form Plugin API provides several methods that allow you to easily manage for ### ajaxForm -Prepares a form to be submitted via AJAX by adding all of the necessary event listeners. It does **not** submit the form. Use `ajaxForm` in your document's `ready` function to prepare your form(s) for AJAX submission. `ajaxForm` takes zero or one argument. The single argument can be either a callback function or an [Options Object](http://malsup.com/jquery/form/#options-object). +Prepares a form to be submitted via AJAX by adding all of the necessary event listeners. It does **not** submit the form. Use `ajaxForm` in your document's `ready` function to prepare your form(s) for AJAX submission. `ajaxForm` takes zero or one argument. The single argument can be either a callback function or an [Options Object](options.md). Chainable: Yes. **Note:** You can pass any of the standard [$.ajax settings](https://api.jquery.com/jQuery.ajax/#jQuery-ajax-settings) to ajaxForm @@ -30,7 +30,7 @@ $(document).ajaxFormUnbind("form.ajax"); ### ajaxSubmit -Immediately submits the form via AJAX. In the most common use case this is invoked in response to the user clicking a submit button on the form. `ajaxSubmit` takes zero or one argument. The single argument can be either a callback function or an [Options Object](http://malsup.com/jquery/form/#options-object). +Immediately submits the form via AJAX. In the most common use case this is invoked in response to the user clicking a submit button on the form. `ajaxSubmit` takes zero or one argument. The single argument can be either a callback function or an [Options Object](options.md). Chainable: Yes. **Note:** You can pass any of the standard [$.ajax settings](https://api.jquery.com/jQuery.ajax/#jQuery-ajax-settings) to ajaxSubmit. @@ -45,6 +45,18 @@ $("#myFormId").submit(function () { }); ``` +### The jqXHR of a submission + +`ajaxSubmit` stores the jqXHR of each submission in the form's data cache under the `jqxhr` key, so you can add callbacks or abort the request after it starts. + +```javascript +var xhr = $("#myFormId").ajaxSubmit().data("jqxhr"); + +xhr.done(function (data) { + // ... +}); +``` + ### formSerialize Serializes the form into a query string. This method will return a string in the format: `name1=value1&name2=value2` @@ -87,7 +99,7 @@ $("#myFormId").resetForm(); ### clearForm -Clears the form elements. This method emptys all of the text inputs, password inputs and textarea elements, clears the selection in any select elements, and unchecks all radio and checkbox inputs. +Clears the form elements. This method empties all of the text inputs, password inputs and textarea elements, clears the selection in any select elements, and unchecks all radio and checkbox inputs. It does _not_ clear hidden inputs, unless you pass `true` (all hidden inputs) or a selector (the hidden inputs that match it), as in `clearForm(".special:hidden")`. `clearFields` takes the same argument. Chainable: Yes. ```javascript @@ -102,3 +114,23 @@ Chainable: Yes. ```javascript $("#myFormId .specialFields").clearFields(); ``` + +### Deprecations + +Features that 5.0 removes still work on 4.x. With debug output on (`$.fn.ajaxSubmit.debug = true`), the plugin logs a `console.warn` the first time each one is used, once per page, naming the replacement. Nothing is logged with debug off. + +| Deprecated | Use instead | +| ---------------------------------------------------------------------------------------------- | ----------------------------------------------------------------- | +| `clearInputs` | `clearFields` | +| `$.fn.attr2` | `.prop()` or `.attr()` | +| `ajaxForm` on an empty selection before the DOM is ready (queued until ready, old jQuery only) | call `ajaxForm` inside `$(fn)`, or use `delegation: ""` | +| the iframe transport chosen automatically because the browser has no `FormData` | set `iframe: true` | +| jQuery before 3.5 (warned on the first `ajaxSubmit` or `ajaxForm`) | jQuery 3.5 or later | +| the `closeKeepAlive` option (a Safari 3/4 workaround) | nothing; leave it out | +| replacing `$.fieldValue` to change what is serialized | jQuery `valHooks` | + +`clearInputs` is now its own function that warns and then calls `clearFields`, so `$.fn.clearInputs !== $.fn.clearFields`. + +A replaced `$.fieldValue` is still used on 4.x, and `formToArray`, `formSerialize`, `fieldSerialize` and `ajaxSubmit` warn when they read through one. In 5.0 they read values without it, so only a jQuery `valHooks` entry changes what they send; `$.fn.fieldValue` keeps reading through `$.fieldValue` and does not warn. + +One warning does not need debug output: `delegation: true` on jQuery 3 and later binds every form on the page, because those versions have no `.selector` to scope it, so it warns on every `ajaxForm` call that uses it. Pass a selector instead, such as `delegation: "form.ajax"`. diff --git a/docs/examples.md b/docs/examples.md index 277eca80..96a72fe5 100644 --- a/docs/examples.md +++ b/docs/examples.md @@ -70,7 +70,7 @@ function showResponse(responseText, statusText, xhr, $form) { } ``` -
+
@@ -118,9 +118,9 @@ function showResponse(responseText, statusText, xhr, $form) {
Name:
- - - + + +
@@ -205,7 +205,7 @@ function showResponse(responseText, statusText, xhr, $form) { } ``` -
+
@@ -253,7 +253,7 @@ function showResponse(responseText, statusText, xhr, $form) {
Name:
- +
#### Output Div (#output2): @@ -271,7 +271,7 @@ The following login form is used for each of the examples that follow. Each exam #### Form Markup: ```html -
+ Username: Password: @@ -290,7 +290,7 @@ $(document).ready(function () { #### Validate Using the `formData` Argument -
+
Username: Password: @@ -322,7 +322,7 @@ function validate(formData, jqForm, options) { #### Validate Using the `jqForm` Argument -
+
Username: Password: @@ -347,7 +347,7 @@ function validate(formData, jqForm, options) { #### Validate Using the `fieldValue` Method -
+
Username: Password: @@ -387,13 +387,13 @@ This page shows how to handle JSON data returned from the server. The form below #### Form markup: ```html - + Message: ``` -
+
Message:
@@ -439,13 +439,13 @@ This page shows how to handle XML data returned from the server. The form below #### Form markup: ```html -
+ Message:
``` -
+
Message:
@@ -497,13 +497,13 @@ This page shows how to handle HTML data returned from the server. The form below #### Form markup: ```html -
+ Message:
``` -
+
Message:
@@ -572,7 +572,7 @@ if (!$xhr) The form below provides an input element of type "file" along with a select element to specify the dataType of the response. The form is submitted to `files.php` which uses the dataType to determine what type of response to return. -
+ File: Return Type: (ie: textarea, [@type='hidden'], :radio, :checkbox, etc)
- [Successful controls](https://www.w3.org/TR/html5/forms.html#constructing-form-data-set) only
+ Successful controls only
@@ -72,7 +72,7 @@ var queryString = $("#myForm :text").fieldSerialize();
-By default, `fieldValue` and `fieldSerialize` only function on '[successful controls](https://www.w3.org/TR/html5/forms.html#constructing-form-data-set)'. This means that if you run the following code on a checkbox that is not checked, the result will be an empty array. +By default, `fieldValue` and `fieldSerialize` only function on '[successful controls](https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#constructing-the-form-data-set)'. This means that if you run the following code on a checkbox that is not checked, the result will be an empty array. ```javascript // value will be an empty array if checkbox is not checked: diff --git a/docs/index.md b/docs/index.md index 7f77a623..5b90bb8d 100644 --- a/docs/index.md +++ b/docs/index.md @@ -16,7 +16,7 @@ The jQuery Form Plugin allows you to easily and unobtrusively upgrade HTML forms ``` -2. Include jQuery and the Form Plugin external script files and a short script to initialize the form when the DOM is ready: +2. Include jQuery and the Form Plugin external script files and a short script to initialize the form when the DOM is ready. The scripts below load from a CDN; to bundle the plugin instead, install it with `npm install jquery-form` and see [Installation](#installation). ```html @@ -26,8 +26,8 @@ The jQuery Form Plugin allows you to easily and unobtrusively upgrade HTML forms crossorigin="anonymous" > @@ -48,4 +48,28 @@ The jQuery Form Plugin allows you to easily and unobtrusively upgrade HTML forms When this form is submitted the _name_ and _comment_ fields will be posted to _comment.php_. If the server returns a success status then the user will see a "Thank you" message. +### Installation + +Install the plugin from npm: + +```sh +npm install jquery-form +``` + +With a bundler, importing the module registers the plugin on the jQuery that `import "jquery"` resolves to: + +```javascript +import $ from "jquery"; +import "jquery-form"; +``` + +With CommonJS, the package exports a factory that takes the window and jQuery, registers the plugin and returns jQuery: + +```javascript +var $ = require("jquery"); +require("jquery-form")(window, $); +``` + +Without a bundler, load `dist/jquery.form.min.js` with a script tag after jQuery, as in the Quick Start above. + *[AJAX]: Asynchronous JavaScript and XML diff --git a/docs/metrics.md b/docs/metrics.md index 074e3f24..dcf81152 100644 --- a/docs/metrics.md +++ b/docs/metrics.md @@ -4,40 +4,40 @@ Before-and-after numbers for the v4 and v5 release announcements. Add a column w Machine: Apple Silicon Mac, Node v24.11.0 (baseline), Node v26.12.1 (Phase 3 onward). -| Metric | v4.3.0 baseline (2026-10-25) | Phase 3 toolchain (2026-10-25) | Phase 3B CI baseline (2026-10-25) | Playwright cache (2026-10-25) | Phase 4B test rewrite (2026-10-25) | Phase 5 coverage (2026-10-25) | Phase 6 deps (2026-10-25) | Phase 7 triage (2026-10-29) | Phase 8 review (2026-10-31) | Phase 9 coverage (2026-10-31) | Phase 10 public fixes (2026-10-31) | 4.4.0 release (2026-11-07) | Phase 12 (local, form members) (2026-11-01) | Phase 12 (local, submission) (2026-11-01) | Phase 12 (local, submission fixes) (2026-11-01) | Phase 12 (local, iframe lifecycle) (2026-11-01) | Phase 12 (local, successful controls) (2026-11-01) | Phase 12 (local, submitter) (2026-11-01) | Phase 12 (local, ajaxForm binding) (2026-11-01) | Phase 12 (local, final) (2026-11-01) | 4.5.0 release (2026-11-10) | -| ------------------------------------------------------- | --------------------------------------------------------------------- | ---------------------------------------------------------------- | ------------------------------------------------------ | ----------------------------------------------------------------- | ---------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------- | ---------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- | -| Test runner | Mocha 7 in PhantomJS via Grunt | Vitest 5 browser mode (Chromium via Playwright) | Unchanged | Unchanged | Unchanged | Unchanged | Unchanged | Unchanged | Unchanged | Unchanged | Unchanged | Unchanged | Unchanged | Unchanged | Unchanged | Unchanged | Unchanged | Unchanged | Unchanged | Unchanged | Unchanged | -| Tests | 59 (async tests do not await their assertions) | 64: the same 59, unmodified, plus 5 publish-surface smoke tests | Unchanged | Unchanged | 64: the same 59 rewritten as BDD/AAA with async assertions awaited, plus 5 surface tests | 194: 189 suite (6 are `it.fails` bug records) plus 5 surface tests | 199: 188 suite (6 are `it.fails`), 5 publish-surface, 6 manifest | 204: 192 suite (10 are `it.fails`, 4 new for open issues), 5 publish-surface, 7 manifest and dist (1 `it.fails`) | Unchanged | 206: 194 suite (9 are `it.fails`; the script response record is now an `it`, plus 2 new tests), 5 publish-surface, 7 manifest and dist (1 `it.fails`) | 229: 217 suite (3 are `it.fails`; 6 records are now `it`, plus 23 new tests), 5 publish-surface, 7 manifest and dist (the #553 record is now an `it`) | 245: 233 suite (1 `it.fails`, delegation; the label and #597 records are now `it`, plus 16 new tests), 5 publish-surface, 7 manifest and dist | 790 suite per jQuery version (1.7.2: 12 skipped; 3.7.1: 1 skipped; 4.0.0: none), 58 `it.fails` on 3.7.1 (10 records are now `it`, plus 19 new tests), 6 publish-surface (1 new: the classic factory is strict), 7 manifest and dist | 793 suite per jQuery version, names identical to before the slice (1.7.2: 12 skipped; 3.7.1: 1 skipped; 4.0.0: none), 58 `it.fails` unchanged, surfaces unchanged | 820 suite per jQuery version (1.7.2: 12 skipped; 3.7.1: 1 skipped; 4.0.0: none), 35 `it.fails` (58 → 35, 23 flipped), surfaces unchanged | 831 suite per jQuery version (1.7.2: 12 skipped; 3.7.1: 1 skipped; 4.0.0: none), 24 `it.fails` (35 → 24, 11 flipped), surfaces unchanged | 849 suite per jQuery version (1.7.2: 12 skipped; 3.7.1: 1 skipped; 4.0.0: none), 17 `it.fails` (23 → 17, 6 flipped), surfaces unchanged | 854 suite per jQuery version (1.7.2: 12 skipped; 3.7.1: 1 skipped; 4.0.0: none), 13 `it.fails` (17 → 13, 4 flipped), surfaces unchanged | 880 suite per jQuery version (1.7.2: 12 skipped; 3.7.1: 1 skipped; 4.0.0: none), 12 `it.fails` (13 → 12, 1 flipped), surfaces unchanged | 900 suite per jQuery version (1.7.2: 14 skipped; 3.7.1: 1 skipped; 4.0.0: none), 2 `it.fails` (12 → 2, 10 flipped), surfaces 5, unchanged | 915 (912 pass, 2 `it.fails` for IFR-122/123, 1 skipped); suite per jQuery version 902 (1.7.2: 14 skipped; 3.7.1: 1 skipped; 4.0.0: none) | -| Suite time | 0.81 s in-browser, 7.0 s wall (`npx grunt mocha`) | 0.53 s in-runner, 0.9 s wall (`npx vitest run`) | Unchanged | Unchanged | 1.15 s in-runner (all projects), includes about 0.6 s of deliberate waits | 3.35 s in-runner (all projects), includes deliberate waits and iframe round trips | 3.35 s in-runner (all projects), 3.8 s wall (`npx vitest run`) | Unchanged | Unchanged | 3.45 s in-runner (all projects), 3.9 s wall (`npx vitest run`) | 3.23 s in-runner (all projects), 3.6 s wall (`npx vitest run`) | 4.69 s wall (`npx vitest run`) | not re-measured | not re-measured | not re-measured | not re-measured | not re-measured | not re-measured | not re-measured | 4.5 s in-runner (`npx vitest run --project suite`, jQuery 3.7.1) | 4.75 s in-runner (`npx vitest run --project suite`, jQuery 3.7.1) | -| Full `npm test` | Not defined | 1.5 s wall (lint, build, tests, coverage) | Unchanged | Unchanged | 2.6 s wall | 4.75 s wall | 6.6 s wall | 6.9 s wall | Unchanged | 5.0 s wall | 4.7 s wall | 8.1 s wall | not re-measured | not re-measured | not re-measured | not re-measured | not re-measured | not re-measured | not re-measured | 7.0 s wall (lint, format check, build, Vitest with coverage) | 7.8 s wall | -| Line coverage of `src` | Not measured by the toolchain (about 60% under the prototype runners) | 35.4% | Unchanged | Unchanged | 35.95% | 98.14% | 98.13% | Unchanged | Unchanged | 100% | Unchanged | Unchanged | 100% (`src/*.js`, 2 files) | 100% (`src/*.js`, 7 files) | 100% (`src/*.js`, 7 files) | 100% (`src/*.js`, 10 files) | 100% (`src/*.js`, 12 files) | 100% (`src/*.js`, 13 files) | 100% (`src/*.js`, 14 files) | 100% (`src/*.js`, 14 files) | 100% | -| Branch coverage of `src` | Not measured (about 53% under the prototype runners) | 33.9% | Unchanged | Unchanged | Unchanged | 96.41% | 96.40% | Unchanged | Unchanged | 100% | Unchanged | Unchanged | 100% | 100% | 100% | 100% | 100% | 100% | 100% | 100% | 100% | -| Function coverage of `src` | Not measured | Not recorded | Unchanged | Unchanged | 43.10% | 98.27% | 98.24% | Unchanged | Unchanged | 100% | Unchanged | Unchanged | 100% | 100% | 100% | 100% | 100% | 100% | 100% | 100% | 100% | -| Statement coverage of `src` | Not measured | Not recorded | Unchanged | Unchanged | 36.77% | 98.17% | 98.16% | Unchanged | Unchanged | 100% | Unchanged | Unchanged | 100% | 100% | 100% | 100% | 100% | 100% | 100% | 100% | 100% | -| Coverage enforced | No | No (reported on every run) | Unchanged | Unchanged | Unchanged | Yes: lines 98.14%, branches 96.41%, functions 98.27%, statements 98.17% | Yes: lines 98.13%, branches 96.4%, functions 98.24%, statements 98.16% (same uncovered code; the `eval` fallback is gone) | Unchanged | Unchanged | Yes: 100% on all four | Unchanged | Unchanged | Unchanged | Unchanged | Unchanged | Unchanged | Unchanged | Unchanged | Unchanged | Unchanged | Unchanged | -| `dist/jquery.form.min.js` | 17.09 kB min, 6.57 kB gzip | 17.18 kB min, 6.57 kB gzip | Unchanged | Unchanged | Unchanged | Unchanged | 17.15 kB min, 6.55 kB gzip | Unchanged | Unchanged | 16.70 kB min, 6.38 kB gzip | 17.10 kB min, 6.57 kB gzip | 17.45 kB min, 6.67 kB gzip | 18.08 kB min, 7.00 kB gzip | 18.93 kB min, 7.36 kB gzip | 20.25 kB min, 7.80 kB gzip | 21.41 kB min, 8.14 kB gzip | 22.26 kB min, 8.46 kB gzip | 22.88 kB min, 8.70 kB gzip | 23.92 kB min, 9.02 kB gzip | 25.49 kB min, 9.59 kB gzip | 25.58 kB min, 9.63 kB gzip | -| `npm audit` | 51 (11 critical, 25 high, 10 moderate, 5 low) | 0 | Unchanged | Unchanged | Unchanged | Unchanged | 0 vulnerabilities | Unchanged | Unchanged | Unchanged | 6 moderate, dev only (`minimatch` via ESLint, GHSA-g3hv-75wg-m249); 0 with `--omit=dev` | 0 (`minimatch` override, PR #638) | not re-measured | not re-measured | not re-measured | not re-measured | not re-measured | not re-measured | not re-measured | not re-measured | 0 | -| Dev dependencies (direct) | 8 | 15 | Unchanged | Unchanged | Unchanged | Unchanged | 15 (no upgrades were available; see `docs/research/jquery-matrix.md`) | Unchanged | Unchanged | Unchanged | Unchanged | Unchanged | Unchanged | Unchanged | Unchanged | Unchanged | Unchanged | Unchanged | Unchanged | Unchanged | Unchanged | -| jQuery versions tested | 3.5.1 only (from the CDN) | 3.7.1 (suite and surfaces), 4.0.0 (ESM surface only) | Unchanged | Unchanged | Unchanged | Unchanged | 1.7.2, 3.7.1 and 4.0.0, all gating in CI; the ESM surface test also loads 4.0.0 | Unchanged | Unchanged | Unchanged | Unchanged | Unchanged | Unchanged | Unchanged | Unchanged (plus a slim-build fixture for 3.7.1 and 4.0.0) | Unchanged | Unchanged | Unchanged | Unchanged | Unchanged | Unchanged | -| CI | Travis and CircleCI configs (inactive) | GitHub Actions (duration recorded after the first run on `main`) | 6 warm runs, median (min–max); 1 cold run. Steps below | 6 warm runs, 1 cold run; steps below | Unchanged | 1 warm run; steps below | Run 40992583331 (warm); the `jquery` matrix jobs run in parallel with `test` | Run 40999832492 (PR, warm) | Run 41227104628 (PR, warm) | Run 41258062402 (PR, warm) | Run 41263541622 (PR, warm) | Run 42332118377 (release PR, warm) | not re-measured | not re-measured | not re-measured | not re-measured | not re-measured | not re-measured | not re-measured | not re-measured | Run 42496815963 (release PR before the version bump, warm) | -| Open issues / PRs | 27 / 8 | 27 / 8 | 27 / 8 | 27 / 8 | Unchanged | 27 / 9 (includes PR #626) | 27 / 9 (includes PR #627) | 12 / 3 (15 issues and 5 PRs closed; closures posted 2026-10-30) | 13 / 1 (#629 opened; PRs #586 and #611 closed) | Unchanged | Unchanged | Unchanged until the release closures | not re-measured | not re-measured | not re-measured | not re-measured | not re-measured | not re-measured | not re-measured | not re-measured | 5 / 2 before the release closures | -| CI queue time | — | — | 3 s (2–3 s) | 3 s (2–3 s) | Unchanged | 3 s | 2 s | 3 s | 3 s | 3 s | 3 s | 2 s | not re-measured | not re-measured | not re-measured | not re-measured | not re-measured | not re-measured | not re-measured | not re-measured | 2 s | -| CI total wall time | — | — | 31 s (27–33 s); cold 32 s | 27 s (22–31 s); cold 36 s | Unchanged | 35 s | 31 s (`test` job) | 29 s (`test` job) | 26 s (`test` job) | 27 s (`test` job) | 32 s (`test` job) | 30 s (`test` job) | not re-measured | not re-measured | not re-measured | not re-measured | not re-measured | not re-measured | not re-measured | not re-measured | 33 s (`test` job) | -| CI step: setup-node (npm cache) | — | — | 6.5 s (5–8 s); cold 5 s | 6.5 s (6–7 s); cold 6 s | Unchanged | 7 s | 6 s | 5 s | 5 s | 6 s | 5 s | 5 s | not re-measured | not re-measured | not re-measured | not re-measured | not re-measured | not re-measured | not re-measured | not re-measured | 5 s | -| CI step: `npm ci` | — | — | 1 s (1–2 s); cold 2 s | 1 s (0–2 s); cold 2 s | Unchanged | 2 s | 2 s | 2 s | 1 s | 1 s | 2 s | 2 s | not re-measured | not re-measured | not re-measured | not re-measured | not re-measured | not re-measured | not re-measured | not re-measured | 2 s | -| CI step: Playwright Chromium install | — | — | 8 s (7–10 s); cold 10 s | 1 s (0–1 s) plus 3 s cache restore; cold 10 s plus 4 s cache save | Unchanged | 1 s plus 4 s cache restore | 1 s (cache 3 s) | 1 s (cache 3 s) | 1 s (cache 2 s) | 1 s (cache 3 s) | 0 s (cache 3 s) | 1 s (cache 3 s) | not re-measured | not re-measured | not re-measured | not re-measured | not re-measured | not re-measured | not re-measured | not re-measured | 1 s (cache 2 s) | -| CI step: lint | — | — | 1 s (0–1 s) | 0 s (0–1 s) | Unchanged | 1 s | 1 s | 1 s | 1 s | 0 s | 1 s | 1 s | not re-measured | not re-measured | not re-measured | not re-measured | not re-measured | not re-measured | not re-measured | not re-measured | 2 s | -| CI step: format check | — | — | 1 s (0–1 s) | 1 s (1–2 s) | Unchanged | 1 s | 1 s | 2 s | 1 s | 1 s | 2 s | 1 s | not re-measured | not re-measured | not re-measured | not re-measured | not re-measured | not re-measured | not re-measured | not re-measured | 2 s | -| CI step: build | — | — | 0.5 s (0–1 s) | 1 s (0–1 s) | Unchanged | 1 s | 1 s | 0 s | 1 s | 1 s | 1 s | 1 s | not re-measured | not re-measured | not re-measured | not re-measured | not re-measured | not re-measured | not re-measured | not re-measured | 1 s | -| CI step: Vitest with coverage | — | — | 3 s (3–4 s) | 2.5 s (1–4 s) | Unchanged | 6 s | 6 s | 7 s | 6 s | 5 s | 8 s | 8 s | not re-measured | not re-measured | not re-measured | not re-measured | not re-measured | not re-measured | not re-measured | not re-measured | 9 s | -| CI step: checkout, job setup, dist check, report upload | — | — | about 1 s each | about 1 s each | Unchanged | 0–2 s each | 0–1 s each | 0–1 s each | 0–1 s each | 0–1 s each | 0–2 s each | 0–1 s each | not re-measured | not re-measured | not re-measured | not re-measured | not re-measured | not re-measured | not re-measured | not re-measured | 0–1 s each | -| Source lines: physical / code / comment-only | 1592 / 1050 / 289 | — | — | — | — | — | — | — | 1562 / 1029 / 279 | 1529 / 999 / 278 | 1584 / 1029 / 292 | 1607 / 1040 / 300 | 1696 / 1086 / 321 (2 files) | 1844 / 1159 / 367 (7 files) | 2023 / 1279 / 391 (7 files) | 2266 / 1432 / 432 (10 files) | 2407 / 1495 / 476 (12 files) | 2517 / 1555 / 502 (13 files) | 2629 / 1642 / 502 (14 files) | 2703 / 1687 / 516 (14 files) | 2704 / 1688 / 516 (14 files) | -| Functions | 60 | — | — | — | — | — | — | — | 57 | 56 | 62 | 64 | 74 | 87 | 96 | 128 | 146 | 155 | 164 | 169 | 169 | -| Cyclomatic complexity: total / mean / max | 417 / 6.95 / 62 | — | — | — | — | — | — | — | 407 / 7.14 / 62 | 386 / 6.89 / 54 | 400 / 6.45 / 52 | 407 / 6.36 / 52 | 421 / 5.69 / 52 | 434 / 4.99 / 48 (`ajaxSubmit` 52 → 4) | 474 / 4.94 / 48 | 510 / 3.98 / 37 | 537 / 3.68 / 15 | 558 / 3.60 / 15 | 583 / 3.55 / 15 | 597 / 3.53 / 15 | 597 / 3.53 / 15 | -| Functions with complexity > 10 | 10 | — | — | — | — | — | — | — | 10 | 10 | Unchanged | 10 | Unchanged | 9 | 10 | 9 | 9 | 9 | 9 | 9 | 9 | -| Max block nesting depth | 5 | — | — | — | — | — | — | — | 5 | 5 | Unchanged | 6 | 6 | 6 | 6 | 5 | 5 | 5 | 5 | 5 | 5 | -| Public API: `$.fn` / `$` members | 14 / 1 | — | — | — | — | — | — | — | 14 / 1 | Unchanged | Unchanged | Unchanged | Unchanged | Unchanged | Unchanged | Unchanged | Unchanged | Unchanged | Unchanged (`ajaxFormUnbind` takes an optional selector) | Unchanged | Unchanged | -| CodeQL alerts (open) | — | — | — | — | — | — | — | — | 3 in `src/` on `main` (alerts 1, 4 and 7) | Unchanged | Unchanged (the PR adds none) | 1 expected (alert 7, `iframeTarget`); alerts 1 and 4 close | Unchanged | Unchanged | Unchanged | Unchanged | Unchanged | Unchanged | Unchanged | Unchanged | 0 (alert 10, the `target` lookup moved by the module split, dismissed; 4.6.0 removes it) | +| Metric | v4.3.0 baseline (2026-10-25) | Phase 3 toolchain (2026-10-25) | Phase 3B CI baseline (2026-10-25) | Playwright cache (2026-10-25) | Phase 4B test rewrite (2026-10-25) | Phase 5 coverage (2026-10-25) | Phase 6 deps (2026-10-25) | Phase 7 triage (2026-10-29) | Phase 8 review (2026-10-31) | Phase 9 coverage (2026-10-31) | Phase 10 public fixes (2026-10-31) | 4.4.0 release (2026-11-07) | Phase 12 (local, form members) (2026-11-01) | Phase 12 (local, submission) (2026-11-01) | Phase 12 (local, submission fixes) (2026-11-01) | Phase 12 (local, iframe lifecycle) (2026-11-01) | Phase 12 (local, successful controls) (2026-11-01) | Phase 12 (local, submitter) (2026-11-01) | Phase 12 (local, ajaxForm binding) (2026-11-01) | Phase 12 (local, final) (2026-11-01) | 4.5.0 release (2026-11-10) | Phase 13 (local, 4.x test hardening) (2026-11-02) | 4.6.0 release (2026-11-14) | +| ------------------------------------------------------- | --------------------------------------------------------------------- | ---------------------------------------------------------------- | ------------------------------------------------------ | ----------------------------------------------------------------- | ---------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------- | ---------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- | +| Test runner | Mocha 7 in PhantomJS via Grunt | Vitest 5 browser mode (Chromium via Playwright) | Unchanged | Unchanged | Unchanged | Unchanged | Unchanged | Unchanged | Unchanged | Unchanged | Unchanged | Unchanged | Unchanged | Unchanged | Unchanged | Unchanged | Unchanged | Unchanged | Unchanged | Unchanged | Unchanged | Vitest 5 browser mode on Chromium, WebKit and Firefox (Firefox in Docker); Playwright Test 1.64.1 and `node:test` for end-to-end and published-file tests | Unchanged | +| Tests | 59 (async tests do not await their assertions) | 64: the same 59, unmodified, plus 5 publish-surface smoke tests | Unchanged | Unchanged | 64: the same 59 rewritten as BDD/AAA with async assertions awaited, plus 5 surface tests | 194: 189 suite (6 are `it.fails` bug records) plus 5 surface tests | 199: 188 suite (6 are `it.fails`), 5 publish-surface, 6 manifest | 204: 192 suite (10 are `it.fails`, 4 new for open issues), 5 publish-surface, 7 manifest and dist (1 `it.fails`) | Unchanged | 206: 194 suite (9 are `it.fails`; the script response record is now an `it`, plus 2 new tests), 5 publish-surface, 7 manifest and dist (1 `it.fails`) | 229: 217 suite (3 are `it.fails`; 6 records are now `it`, plus 23 new tests), 5 publish-surface, 7 manifest and dist (the #553 record is now an `it`) | 245: 233 suite (1 `it.fails`, delegation; the label and #597 records are now `it`, plus 16 new tests), 5 publish-surface, 7 manifest and dist | 790 suite per jQuery version (1.7.2: 12 skipped; 3.7.1: 1 skipped; 4.0.0: none), 58 `it.fails` on 3.7.1 (10 records are now `it`, plus 19 new tests), 6 publish-surface (1 new: the classic factory is strict), 7 manifest and dist | 793 suite per jQuery version, names identical to before the slice (1.7.2: 12 skipped; 3.7.1: 1 skipped; 4.0.0: none), 58 `it.fails` unchanged, surfaces unchanged | 820 suite per jQuery version (1.7.2: 12 skipped; 3.7.1: 1 skipped; 4.0.0: none), 35 `it.fails` (58 → 35, 23 flipped), surfaces unchanged | 831 suite per jQuery version (1.7.2: 12 skipped; 3.7.1: 1 skipped; 4.0.0: none), 24 `it.fails` (35 → 24, 11 flipped), surfaces unchanged | 849 suite per jQuery version (1.7.2: 12 skipped; 3.7.1: 1 skipped; 4.0.0: none), 17 `it.fails` (23 → 17, 6 flipped), surfaces unchanged | 854 suite per jQuery version (1.7.2: 12 skipped; 3.7.1: 1 skipped; 4.0.0: none), 13 `it.fails` (17 → 13, 4 flipped), surfaces unchanged | 880 suite per jQuery version (1.7.2: 12 skipped; 3.7.1: 1 skipped; 4.0.0: none), 12 `it.fails` (13 → 12, 1 flipped), surfaces unchanged | 900 suite per jQuery version (1.7.2: 14 skipped; 3.7.1: 1 skipped; 4.0.0: none), 2 `it.fails` (12 → 2, 10 flipped), surfaces 5, unchanged | 915 (912 pass, 2 `it.fails` for IFR-122/123, 1 skipped); suite per jQuery version 902 (1.7.2: 14 skipped; 3.7.1: 1 skipped; 4.0.0: none) | 1207 suite per jQuery version (1.7.2: 48 skipped; 3.7.1: 35; 4.0.0: 34; most skips are oracle seeds with no submitter), 0 `it.fails` (2 flipped), surfaces 5; plus 237 end-to-end tests per browser and 13 Node published-file tests. Mutation score 91.67% → 94.34% (Stryker, one-off, local) | 1219 suite per jQuery version (1.7.2: 48 skipped; 3.7.1: 35; 4.0.0: 34), 0 `it.fails`, surfaces 5; end-to-end on 3 browsers × 3 jQuery versions in CI | +| Suite time | 0.81 s in-browser, 7.0 s wall (`npx grunt mocha`) | 0.53 s in-runner, 0.9 s wall (`npx vitest run`) | Unchanged | Unchanged | 1.15 s in-runner (all projects), includes about 0.6 s of deliberate waits | 3.35 s in-runner (all projects), includes deliberate waits and iframe round trips | 3.35 s in-runner (all projects), 3.8 s wall (`npx vitest run`) | Unchanged | Unchanged | 3.45 s in-runner (all projects), 3.9 s wall (`npx vitest run`) | 3.23 s in-runner (all projects), 3.6 s wall (`npx vitest run`) | 4.69 s wall (`npx vitest run`) | not re-measured | not re-measured | not re-measured | not re-measured | not re-measured | not re-measured | not re-measured | 4.5 s in-runner (`npx vitest run --project suite`, jQuery 3.7.1) | 4.75 s in-runner (`npx vitest run --project suite`, jQuery 3.7.1) | 4.5 s in-runner (`npx vitest run --project suite-chromium`, jQuery 3.7.1) | 4.72 s in-runner (`npx vitest run --project suite-chromium`, jQuery 3.7.1) | +| Full `npm test` | Not defined | 1.5 s wall (lint, build, tests, coverage) | Unchanged | Unchanged | 2.6 s wall | 4.75 s wall | 6.6 s wall | 6.9 s wall | Unchanged | 5.0 s wall | 4.7 s wall | 8.1 s wall | not re-measured | not re-measured | not re-measured | not re-measured | not re-measured | not re-measured | not re-measured | 7.0 s wall (lint, format check, build, Vitest with coverage) | 7.8 s wall | 12.3 s wall (adds a WebKit run); `npm run test:e2e` 26.5 s wall | 13 s wall (without the untracked probe files) | +| Line coverage of `src` | Not measured by the toolchain (about 60% under the prototype runners) | 35.4% | Unchanged | Unchanged | 35.95% | 98.14% | 98.13% | Unchanged | Unchanged | 100% | Unchanged | Unchanged | 100% (`src/*.js`, 2 files) | 100% (`src/*.js`, 7 files) | 100% (`src/*.js`, 7 files) | 100% (`src/*.js`, 10 files) | 100% (`src/*.js`, 12 files) | 100% (`src/*.js`, 13 files) | 100% (`src/*.js`, 14 files) | 100% (`src/*.js`, 14 files) | 100% | 100% (`src/*.js`, 14 files) | 100% | +| Branch coverage of `src` | Not measured (about 53% under the prototype runners) | 33.9% | Unchanged | Unchanged | Unchanged | 96.41% | 96.40% | Unchanged | Unchanged | 100% | Unchanged | Unchanged | 100% | 100% | 100% | 100% | 100% | 100% | 100% | 100% | 100% | 100% | 100% | +| Function coverage of `src` | Not measured | Not recorded | Unchanged | Unchanged | 43.10% | 98.27% | 98.24% | Unchanged | Unchanged | 100% | Unchanged | Unchanged | 100% | 100% | 100% | 100% | 100% | 100% | 100% | 100% | 100% | 100% | 100% | +| Statement coverage of `src` | Not measured | Not recorded | Unchanged | Unchanged | 36.77% | 98.17% | 98.16% | Unchanged | Unchanged | 100% | Unchanged | Unchanged | 100% | 100% | 100% | 100% | 100% | 100% | 100% | 100% | 100% | 100% | 100% | +| Coverage enforced | No | No (reported on every run) | Unchanged | Unchanged | Unchanged | Yes: lines 98.14%, branches 96.41%, functions 98.27%, statements 98.17% | Yes: lines 98.13%, branches 96.4%, functions 98.24%, statements 98.16% (same uncovered code; the `eval` fallback is gone) | Unchanged | Unchanged | Yes: 100% on all four | Unchanged | Unchanged | Unchanged | Unchanged | Unchanged | Unchanged | Unchanged | Unchanged | Unchanged | Unchanged | Unchanged | Unchanged | Unchanged | +| `dist/jquery.form.min.js` | 17.09 kB min, 6.57 kB gzip | 17.18 kB min, 6.57 kB gzip | Unchanged | Unchanged | Unchanged | Unchanged | 17.15 kB min, 6.55 kB gzip | Unchanged | Unchanged | 16.70 kB min, 6.38 kB gzip | 17.10 kB min, 6.57 kB gzip | 17.45 kB min, 6.67 kB gzip | 18.08 kB min, 7.00 kB gzip | 18.93 kB min, 7.36 kB gzip | 20.25 kB min, 7.80 kB gzip | 21.41 kB min, 8.14 kB gzip | 22.26 kB min, 8.46 kB gzip | 22.88 kB min, 8.70 kB gzip | 23.92 kB min, 9.02 kB gzip | 25.49 kB min, 9.59 kB gzip | 25.58 kB min, 9.63 kB gzip | 26.24 kB min, 9.93 kB gzip | 26.54 kB min, 10.09 kB gzip | +| `npm audit` | 51 (11 critical, 25 high, 10 moderate, 5 low) | 0 | Unchanged | Unchanged | Unchanged | Unchanged | 0 vulnerabilities | Unchanged | Unchanged | Unchanged | 6 moderate, dev only (`minimatch` via ESLint, GHSA-g3hv-75wg-m249); 0 with `--omit=dev` | 0 (`minimatch` override, PR #638) | not re-measured | not re-measured | not re-measured | not re-measured | not re-measured | not re-measured | not re-measured | not re-measured | 0 | 0 (`minimatch` overridden to 11.0.4, CVE-2026-118764) | 0 | +| Dev dependencies (direct) | 8 | 15 | Unchanged | Unchanged | Unchanged | Unchanged | 15 (no upgrades were available; see `docs/research/jquery-matrix.md`) | Unchanged | Unchanged | Unchanged | Unchanged | Unchanged | Unchanged | Unchanged | Unchanged | Unchanged | Unchanged | Unchanged | Unchanged | Unchanged | Unchanged | 17 (adds `@playwright/test` and `jsdom`) | Unchanged (17) | +| jQuery versions tested | 3.5.1 only (from the CDN) | 3.7.1 (suite and surfaces), 4.0.0 (ESM surface only) | Unchanged | Unchanged | Unchanged | Unchanged | 1.7.2, 3.7.1 and 4.0.0, all gating in CI; the ESM surface test also loads 4.0.0 | Unchanged | Unchanged | Unchanged | Unchanged | Unchanged | Unchanged | Unchanged | Unchanged (plus a slim-build fixture for 3.7.1 and 4.0.0) | Unchanged | Unchanged | Unchanged | Unchanged | Unchanged | Unchanged | Unchanged versions, now on Chromium, WebKit and Firefox; plus the packed package by script tag, RequireJS, import map, CommonJS and ESM | Unchanged | +| CI | Travis and CircleCI configs (inactive) | GitHub Actions (duration recorded after the first run on `main`) | 6 warm runs, median (min–max); 1 cold run. Steps below | 6 warm runs, 1 cold run; steps below | Unchanged | 1 warm run; steps below | Run 40992583331 (warm); the `jquery` matrix jobs run in parallel with `test` | Run 40999832492 (PR, warm) | Run 41227104628 (PR, warm) | Run 41258062402 (PR, warm) | Run 41263541622 (PR, warm) | Run 42332118377 (release PR, warm) | not re-measured | not re-measured | not re-measured | not re-measured | not re-measured | not re-measured | not re-measured | not re-measured | Run 42496815963 (release PR before the version bump, warm) | Adds WebKit and Firefox to the jQuery matrix and an end-to-end job (3 browsers × 3 jQuery); not run until pushed | Run 42936871916 (release PR before the version bump, warm); the first CI run of the WebKit, Firefox and end-to-end jobs, all passing | +| Open issues / PRs | 27 / 8 | 27 / 8 | 27 / 8 | 27 / 8 | Unchanged | 27 / 9 (includes PR #626) | 27 / 9 (includes PR #627) | 12 / 3 (15 issues and 5 PRs closed; closures posted 2026-10-30) | 13 / 1 (#629 opened; PRs #586 and #611 closed) | Unchanged | Unchanged | Unchanged until the release closures | not re-measured | not re-measured | not re-measured | not re-measured | not re-measured | not re-measured | not re-measured | not re-measured | 5 / 2 before the release closures | not re-measured | 3 / 1 (the release PR) before the release closures | +| CI queue time | — | — | 3 s (2–3 s) | 3 s (2–3 s) | Unchanged | 3 s | 2 s | 3 s | 3 s | 3 s | 3 s | 2 s | not re-measured | not re-measured | not re-measured | not re-measured | not re-measured | not re-measured | not re-measured | not re-measured | 2 s | not re-measured | 10 s | +| CI total wall time | — | — | 31 s (27–33 s); cold 32 s | 27 s (22–31 s); cold 36 s | Unchanged | 35 s | 31 s (`test` job) | 29 s (`test` job) | 26 s (`test` job) | 27 s (`test` job) | 32 s (`test` job) | 30 s (`test` job) | not re-measured | not re-measured | not re-measured | not re-measured | not re-measured | not re-measured | not re-measured | not re-measured | 33 s (`test` job) | not re-measured | 96 s (`test` job) | +| CI step: setup-node (npm cache) | — | — | 6.5 s (5–8 s); cold 5 s | 6.5 s (6–7 s); cold 6 s | Unchanged | 7 s | 6 s | 5 s | 5 s | 6 s | 5 s | 5 s | not re-measured | not re-measured | not re-measured | not re-measured | not re-measured | not re-measured | not re-measured | not re-measured | 5 s | not re-measured | 7 s | +| CI step: `npm ci` | — | — | 1 s (1–2 s); cold 2 s | 1 s (0–2 s); cold 2 s | Unchanged | 2 s | 2 s | 2 s | 1 s | 1 s | 2 s | 2 s | not re-measured | not re-measured | not re-measured | not re-measured | not re-measured | not re-measured | not re-measured | not re-measured | 2 s | not re-measured | 2 s | +| CI step: Playwright Chromium install | — | — | 8 s (7–10 s); cold 10 s | 1 s (0–1 s) plus 3 s cache restore; cold 10 s plus 4 s cache save | Unchanged | 1 s plus 4 s cache restore | 1 s (cache 3 s) | 1 s (cache 3 s) | 1 s (cache 2 s) | 1 s (cache 3 s) | 0 s (cache 3 s) | 1 s (cache 3 s) | not re-measured | not re-measured | not re-measured | not re-measured | not re-measured | not re-measured | not re-measured | not re-measured | 1 s (cache 2 s) | not re-measured | 49 s (Chromium and WebKit with system dependencies; cache 5 s) | +| CI step: lint | — | — | 1 s (0–1 s) | 0 s (0–1 s) | Unchanged | 1 s | 1 s | 1 s | 1 s | 0 s | 1 s | 1 s | not re-measured | not re-measured | not re-measured | not re-measured | not re-measured | not re-measured | not re-measured | not re-measured | 2 s | not re-measured | 1 s | +| CI step: format check | — | — | 1 s (0–1 s) | 1 s (1–2 s) | Unchanged | 1 s | 1 s | 2 s | 1 s | 1 s | 2 s | 1 s | not re-measured | not re-measured | not re-measured | not re-measured | not re-measured | not re-measured | not re-measured | not re-measured | 2 s | not re-measured | 2 s | +| CI step: build | — | — | 0.5 s (0–1 s) | 1 s (0–1 s) | Unchanged | 1 s | 1 s | 0 s | 1 s | 1 s | 1 s | 1 s | not re-measured | not re-measured | not re-measured | not re-measured | not re-measured | not re-measured | not re-measured | not re-measured | 1 s | not re-measured | 1 s | +| CI step: Vitest with coverage | — | — | 3 s (3–4 s) | 2.5 s (1–4 s) | Unchanged | 6 s | 6 s | 7 s | 6 s | 5 s | 8 s | 8 s | not re-measured | not re-measured | not re-measured | not re-measured | not re-measured | not re-measured | not re-measured | not re-measured | 9 s | not re-measured | 8 s, plus 12 s for the WebKit suite | +| CI step: checkout, job setup, dist check, report upload | — | — | about 1 s each | about 1 s each | Unchanged | 0–2 s each | 0–1 s each | 0–1 s each | 0–1 s each | 0–1 s each | 0–2 s each | 0–1 s each | not re-measured | not re-measured | not re-measured | not re-measured | not re-measured | not re-measured | not re-measured | not re-measured | 0–1 s each | not re-measured | 0–1 s each | +| Source lines: physical / code / comment-only | 1592 / 1050 / 289 | — | — | — | — | — | — | — | 1562 / 1029 / 279 | 1529 / 999 / 278 | 1584 / 1029 / 292 | 1607 / 1040 / 300 | 1696 / 1086 / 321 (2 files) | 1844 / 1159 / 367 (7 files) | 2023 / 1279 / 391 (7 files) | 2266 / 1432 / 432 (10 files) | 2407 / 1495 / 476 (12 files) | 2517 / 1555 / 502 (13 files) | 2629 / 1642 / 502 (14 files) | 2703 / 1687 / 516 (14 files) | 2704 / 1688 / 516 (14 files) | 2774 / 1736 / 527 (14 files) | 2817 / 1759 / 538 (14 files) | +| Functions | 60 | — | — | — | — | — | — | — | 57 | 56 | 62 | 64 | 74 | 87 | 96 | 128 | 146 | 155 | 164 | 169 | 169 | 174 | 176 | +| Cyclomatic complexity: total / mean / max | 417 / 6.95 / 62 | — | — | — | — | — | — | — | 407 / 7.14 / 62 | 386 / 6.89 / 54 | 400 / 6.45 / 52 | 407 / 6.36 / 52 | 421 / 5.69 / 52 | 434 / 4.99 / 48 (`ajaxSubmit` 52 → 4) | 474 / 4.94 / 48 | 510 / 3.98 / 37 | 537 / 3.68 / 15 | 558 / 3.60 / 15 | 583 / 3.55 / 15 | 597 / 3.53 / 15 | 597 / 3.53 / 15 | 617 / 3.55 / 15 | 623 / 3.54 / 15 | +| Functions with complexity > 10 | 10 | — | — | — | — | — | — | — | 10 | 10 | Unchanged | 10 | Unchanged | 9 | 10 | 9 | 9 | 9 | 9 | 9 | 9 | 10 | 10 | +| Max block nesting depth | 5 | — | — | — | — | — | — | — | 5 | 5 | Unchanged | 6 | 6 | 6 | 6 | 5 | 5 | 5 | 5 | 5 | 5 | 5 | 5 | +| Public API: `$.fn` / `$` members | 14 / 1 | — | — | — | — | — | — | — | 14 / 1 | Unchanged | Unchanged | Unchanged | Unchanged | Unchanged | Unchanged | Unchanged | Unchanged | Unchanged | Unchanged (`ajaxFormUnbind` takes an optional selector) | Unchanged | Unchanged | Unchanged | Unchanged | +| CodeQL alerts (open) | — | — | — | — | — | — | — | — | 3 in `src/` on `main` (alerts 1, 4 and 7) | Unchanged | Unchanged (the PR adds none) | 1 expected (alert 7, `iframeTarget`); alerts 1 and 4 close | Unchanged | Unchanged | Unchanged | Unchanged | Unchanged | Unchanged | Unchanged | Unchanged | 0 (alert 10, the `target` lookup moved by the module split, dismissed; 4.6.0 removes it) | Unchanged | 0 | How measured: CI timings from `scripts/ci-timings.sh ` (GitHub job step timestamps, whole seconds) over run 40225846996 (Phase 3B baseline; the Playwright cache column is run 40227654269, attempt 1 cold and attempts 2–7 warm; the Phase 5 column is run 40233863662, attempt 1, warm), attempts 3–8 warm (npm cache hit) and attempt 2 cold (after `gh cache delete --all`); suite time from runner output and `time`; coverage from `npm test` (v8); gzip via `gzip -c | wc -c`; issue and PR counts via `gh issue list` and `gh pr list`. @@ -62,3 +62,7 @@ The Phase 12 (local, ajaxForm binding) column is the same branch after the bindi The Phase 12 (local, final) column is the same branch after the last Phase 12 commits: debug-only deprecation warnings (`clearInputs`, `attr2`, the DOM-not-ready `ajaxForm` queue, the automatic iframe transport, jQuery before 3.5), the `target` sanitizing, trusted-options and iframe-response docs, and the remaining fixes (D-12, D-13, D-15, D-19, D-25, the FormData `beforeSend` veto). Times are from `npm test` (without the untracked probe files) and the suite project on jQuery 3.7.1, one warm run each on Node v26.12.1. The 4.5.0 release column is the `release-4.5.0` branch with the version bump. Times are from `npm test` and the suite project on each jQuery version, one warm run each on Node v26.12.1. The CI rows are the last PR run before the bump, which changed only the version strings. CodeQL alert 10 was dismissed on 2026-11-10 because the `target` and `iframeTarget` options are trusted input; 4.6.0 looks their strings up only as selectors. + +The Phase 13 column is the local `phase-13` branch after the test-hardening steps and the 4.6.0 fixes, on Node v26.12.1, one warm run each. Test counts are from the Chromium suite on each jQuery version; the same counts pass on WebKit and on Firefox (in Docker, `npm run test:docker`). `npm test` now also runs the suite on WebKit, which is most of the added time. The end-to-end time is `npm run test:e2e` on Chromium and WebKit with jQuery 3.7.1. The mutation score is from one local Stryker 10 run over `src/*.js` against the Chromium suite on jQuery 3.7.1 (2151 mutants; timeouts count as detected); Stryker is not a dependency. + +The 4.6.0 release column is the `release-4.6.0` branch with the version bump, on Node v26.12.1, one warm run each. Test counts are from the Chromium suite on each jQuery version; the suite has 12 more tests than in the Phase 13 column. `npm test` was run without the untracked probe files (lint and format check over tracked files only). The CI rows are the last PR run before the bump, which changed only the version strings; the Playwright install step now installs Chromium and WebKit with their system dependencies, which is most of the added CI time. CodeQL alert 10 (dismissed in 4.5.0) has no code left to flag: `target` and `iframeTarget` strings are looked up only as selectors. diff --git a/docs/options.md b/docs/options.md index f265e6ce..e4eb022f 100644 --- a/docs/options.md +++ b/docs/options.md @@ -6,6 +6,17 @@ Both `ajaxForm` and `ajaxSubmit` support numerous options which can be provided using plain JavaScript `options` object containing any of the options below: **Note:** Aside from the options listed below, you can also pass any of the standard [$.ajax settings](https://api.jquery.com/jQuery.ajax/#jQuery-ajax-settings) to ajaxForm and ajaxSubmit. +### beforeFormUnbind + +Default: `null` +Callback function invoked by `ajaxForm` just before it removes the form's handlers and binds them again, so it runs each time `ajaxForm` is called on the form. It provides a chance to manipulate the form before the events are bound again. It is invoked with two arguments: the jQuery object for the form, and the Options Object passed into `ajaxForm`. It is not called for a `delegation` binding. + +```javascript +beforeFormUnbind: function($form, options) { + // your callback code +} +``` + ### beforeSerialize Default: `null` @@ -48,7 +59,7 @@ data: { key1: 'value1', key2: 'value2' } ### dataType Default: `null` -Expected data type of the response. One of: null, 'xml', 'script', or 'json'. The `dataType` option provides a means for specifying how the server response should be handled. This maps directly to the `jQuery.httpData` method. The following values are supported: +Expected data type of the response. One of: null, 'xml', 'script', or 'json'. The `dataType` option provides a means for specifying how the server response should be handled. It is passed to `$.ajax` as its `dataType`; the iframe transport parses the response the same way. The following values are supported: **'xml'**: if dataType == 'xml' the server response is treated as XML and the 'success' callback method, if specified, will be passed the responseXML value @@ -76,6 +87,19 @@ Callback function to be invoked upon error. It is passed the following arguments 3. `errorThrown`, string 4. `$form` jQuery object containing form element +### filtering + +Default: `null` +Callback function that filters the fields before they are serialized. It is called with each field element and its index, as `jQuery.map` calls its callback: return the element to keep it, or `null` or `undefined` to leave it out. + +```javascript +filtering: function(el, index) { + if (!$(el).hasClass("ignore")) { + return el; + } +} +``` + ### forceSync Default: `false` @@ -84,7 +108,7 @@ Boolean value. Set to true to remove short delay before posting form when upload ### iframe Default: `false` -Boolean flag indicating whether the form should always target the server response to an iframe. This is useful in conjuction with file uploads. See the _File Uploads_ documentation on the [Code Samples](#code-samples) page for more info. +Boolean flag indicating whether the form should always target the server response to an iframe. This is useful in conjuction with file uploads. See the [file upload example](examples.md#file-upload). Without `FormData`, a form with a selected file or a multipart `enctype` also uses the iframe. Choosing it automatically is deprecated (a `debug` warning); 5.0 uses the iframe only when `iframe: true` is set. @@ -104,7 +128,8 @@ String value that should be used for the iframe's src attribute when/if an ifram ### iframeTarget Default: `null` -Identifies the iframe element to be used as the response target for file uploads. By default, the plugin will create a temporary iframe element to capture the response when uploading files. This options allows you to use an existing iframe if you wish. When using this option the plugin will make no attempt at handling the response from the server. **(version added: 2.76)** +Identifies the iframe element to be used as the response target for file uploads. By default, the plugin will create a temporary iframe element to capture the response when uploading files. This options allows you to use an existing iframe if you wish. When using this option the plugin will make no attempt at handling the response from the server. **(version added: 2.76)** +A string is only ever a selector, never parsed as HTML: one that starts with `<` matches nothing. **(since 4.6.0)** ### method @@ -120,7 +145,7 @@ Optionally used along with the the [`target`](#target) option. Set to `true` if ### requestFormat Default: `null` -Set to `"json"` to send the form as a JSON body instead of a urlencoded one (#545). The fields become an object, a name used more than once becomes an array of its values, and an object [`data`](#data) option is merged over them. The request is sent with `contentType: "application/json; charset=UTF-8"`, replacing any `contentType` you pass. It needs a method with a body: a `GET` method (including a form without a `method` attribute) throws an error, as do a string `data` option, a selected file, a multipart form and the [`iframe`](#iframe) option. **(version added: 4.5.0)** Based on the idea in PR #557 by zhangciwu (changwei). +Set to `"json"` to send the form as a JSON body instead of a urlencoded one ([#545](https://github.com/jquery-form/form/issues/545)). The fields become an object, a name used more than once becomes an array of its values, and an object [`data`](#data) option is merged over them. The request is sent with `contentType: "application/json; charset=UTF-8"`, replacing any `contentType` you pass. It needs a method with a body: a `GET` method (including a form without a `method` attribute) throws an error, as do a string `data` option, a selected file, a multipart form and the [`iframe`](#iframe) option. **(version added: 4.5.0)** Based on the idea in PR [#557](https://github.com/jquery-form/form/pull/557) by zhangciwu (changwei). ### resetForm @@ -146,7 +171,7 @@ Callback function to be invoked after the form has been submitted. If a 'success ### target Default: `null` -Identifies the element(s) in the page to be updated with the server response. This value may be specified as a jQuery selection string, a jQuery object, or a DOM element. +Identifies the element(s) in the page to be updated with the server response. This value may be specified as a jQuery selection string, a jQuery object, or a DOM element. A string is only ever a selector, never parsed as HTML: one that starts with `<` matches nothing. **(since 4.6.0)** The response is inserted as HTML, as `$.fn.load` does, so the endpoint must return markup you trust. To sanitize it, filter it with [`dataFilter`](https://api.jquery.com/jQuery.ajax/#jQuery-ajax-settings), which runs before the response reaches the target on both the XHR and the iframe transport: diff --git a/docs/plans/modernization.md b/docs/plans/modernization.md index fc61c054..96a21c67 100644 --- a/docs/plans/modernization.md +++ b/docs/plans/modernization.md @@ -57,13 +57,13 @@ content: "Security and bug fixes: private advisories, review findings, P1 and Ph status: completed - id: release-4x content: "Phase 11: release 4.4.0 with Phases 0-10 and the W1-W4 fixes, publish with npm provenance, publish the advisories and release notes" -status: pending +status: completed - id: cleanup-4x content: "Phase 12: 4.x cleanup and rearchitecture without breaking changes (source modules, lower complexity, additive options, deprecations), then a 4.x minor release" status: completed - id: hardening-4x content: "Phase 13: 4.x test hardening (cross-browser suite, serialization oracle against native FormData, end-to-end tests with a real server, published-file tests, a one-off mutation-testing report), then the 4.6.0 release" -status: pending +status: in_progress - id: breaking-5 content: "Phase 14: 5.0 with a jQuery >=3.5 peer, exports map, no jQuery <3 or IE/Opera shims, explicit iframe transport and delegation selector" status: pending @@ -306,7 +306,7 @@ enforces it. Each removed branch and the reason it was dead are in `docs/researc branch until release day. - Four draft advisories exist: the two accepted reports (severity high) and W3 and W4 (severity medium). CVEs were requested for all four on 2026-10-31. Reporters are not invited as - collaborators. Set `patched_versions` on each before publishing. + collaborators beyond their own reports. Set `patched_versions` on each before publishing. - A custom CodeQL query that catches W1–W4, which the built-in queries miss. It must flag them before the fixes and pass after. Keep it private until the fixed release ships, since it reveals the sinks. - The review's findings 4, 6, 7 and 8. Fixing finding 7 also clears the three `no-prototype-builtins` warnings. @@ -331,6 +331,16 @@ are in `docs/research/4x-behavior-changes.md`. Status (2026-11-07): released without waiting for CVE IDs, which were still unassigned. The W1–W4 details are now in `security-review.md` and the behavior changes in `4x-behavior-changes.md`. +- 4.4.0 is on npm from a06a0c8 (PR #639), with provenance. The four advisories are published with + `patched_versions` 4.4.0; GHSA-x8mc and GHSA-8395 carry the CVSS 3.1 vector + `AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N` (6.1, Medium) instead of the drafted High. +- Release notes are on the `v4.4.0` GitHub release. #604, #554, #553, #588, #597, #600, #616 and #618 + are closed; the drupal.org comment is posted. CodeQL alerts 1 and 4 are fixed and alert 7 is + dismissed, so `main` has no open alerts. +- Left: step 9 when the CVE IDs arrive. Done since: PR #640; the README and site CDN snippets on + jsDelivr (PR #641, then 4.5.0 in PR #643); a Packagist webhook. The cdnjs alternative snippet + moved to the 4.6.0 docs cleanup (Phase 13). + Prepare in public (normal PRs, nothing about W1–W4): - A release workflow (`.github/workflows/release.yml`) that publishes a `v*` tag to npm with npm @@ -338,8 +348,26 @@ Prepare in public (normal PRs, nothing about W1–W4): before publishing. - On npmjs.com, the maintainer adds that workflow as the trusted publisher for `jquery-form`. Then set publishing access to require 2FA and disallow tokens, and review the package's maintainer list. -- Wait until GitHub has assigned a CVE ID to each of the four draft advisories. Review their text, - affected range (`<= 4.3.0`) and credits. +- Review the four draft advisories: text, affected range (`<= 4.3.0`), credits, and any reviewer + comments on the CVE requests. Don't wait for the CVE IDs (see Release train). + - Reviewed 2026-11-07: GitHub has left no comments and assigned no CVEs. Rudloff is credited and + accepted on both reports, and is a collaborator as their author (we invited no one). Their one + comment points to the public drupal.org issue. + - "Found during the Phase 8 security review" in GHSA-g7mw and GHSA-4w39 now reads "Found during a + maintainer security review" (2026-11-07). +- Trial run of `release.yml` on `main` passed on 2026-11-06 (run 42311458706). The trusted publisher + is set up on npmjs.com with publish permission only, not dist-tag. Publishing requires 2FA and + disallows tokens, and the inactive maintainers were removed (2026-11-07). +- Merge the `docs-site-internal-docs` PR. The docs site served `docs/plans/`, `docs/research/`, + `docs/agents/`, `docs/adr/` and `docs/metrics.md`; it now excludes them, so `security-review.md` + isn't published on the site when the W1–W4 details move into it. After the merge, check that + `https://jquery-form.github.io/form/plans/modernization/` returns 404. + - The same PR (#636) unblocks docs-only PRs: `ci.yml` no longer uses `paths-ignore` on pull + requests, and a `changes` job makes the required `test` and jQuery jobs skip their slow steps. + When `phase-13` rebases onto it, `ci.yml` will conflict: keep the step gating on `test` and + the jQuery matrix, and skip the new browser and end-to-end jobs with a job-level + `if: needs.changes.outputs.code == 'true'` (they aren't required checks, so a skipped job is + fine there). - Check that the custom CodeQL query pack resolves its `codeql/javascript-all` dependency in Actions, since it couldn't be run there before release day. @@ -358,11 +386,66 @@ Release day, in one sitting: 4. Tag `v4.4.0` on the merge commit and push the tag. The workflow publishes to npm. Check `npm view jquery-form`, the provenance badge, jsDelivr, cdnjs (git autoupdate) and Packagist. 5. Set `patched_versions` to `4.4.0` on the four advisories and publish them. GitHub then publishes - the CVE records and the GitHub Advisory Database entries, which feed `npm audit` and Dependabot. -6. Publish the GitHub release notes from `4x-behavior-changes.md`. + the GitHub Advisory Database entries, which feed `npm audit` and Dependabot. The CVE requests + stay open and GitHub adds the IDs to the published advisories when it assigns them. +6. Publish the GitHub release notes, written from `4x-behavior-changes.md` but not copied: follow the + public-text rule in `docs/agents/coding-standards.md` (no phases, no internal IDs such as `W1` or + `D-09`, no links to `docs/research/`). Cite the GHSA IDs and say the CVE IDs are pending. The same + rule applies to the issue and drupal.org comments in step 7. 7. Comment on and close #604, #554, #553, #588, #597, #600, #616 and #618. Comment on drupal.org #3607794. Credit Rudloff for W1 and W2. -8. Delete the local fix branch and the probe copies. + - Check that CodeQL alerts 1 and 4 closed. Dismiss alert 7 (`iframeTarget`) as "won't fix", + linking finding 11 in `security-review.md`: the option is a developer-supplied selector. +8. Delete the local fix branch. Keep the probe copies until the modernization project ends: they + keep checking the W1–W4 fixes through the 5.0 refactors. +9. When GitHub assigns the CVE IDs, add them to the 4.4.0 release notes, `security-review.md`, + `4x-behavior-changes.md` and the drupal.org issue. Don't request IDs from another CNA meanwhile; + a second request can produce duplicate CVEs. + +## Release train: 4.4.0, 4.5.0, 4.6.0 + +Decided on 2026-11-06: ship without waiting for CVE IDs. The four CVE requests had no IDs and no +GitHub activity after 6 days, one finding is already public on drupal.org, and the GHSA IDs alone +drive `npm audit`, Dependabot and OSV. What waits for the CVEs: scanners that read only NVD, and the +CVE references in our own docs (Phase 11, step 9). + +The local branches are stacked: `phase-10-advisories` (the W1–W4 fixes) is in `phase-12`, which is +in `phase-13`, which is in `phase-14`. So until the advisories are published: + +- Push none of those branches and open no PR from them. Each one reveals the W1–W4 fixes. +- Public PRs to `main` stay limited to work that names no W1–W4 sink. + +The order: + +1. **4.4.0** (Phase 11). Done 2026-11-07, and the stacked branches are rebased (backups under + `refs/backup/pre-4.4.0/`). Release day as above. Afterwards, rebase `phase-12` on `main` with + `git rebase --onto main phase-10-advisories phase-12` if the fix commits were rebased or squashed + on the way in, then rebase `phase-13` and `phase-14` the same way onto the new tips. +2. **Soak 4.4.0 for about a week** (until about 2026-11-14). Watch issues, npm downloads and the CDN builds. A regression goes + out as 4.4.1 from `main` before 4.5.0, and `phase-12` rebases on it. +3. **4.5.0** (Phase 12). Push `phase-12` and open its PR; this is the first CI and CodeQL run for + those commits, so leave time for fixes. Run the custom CodeQL query. Bump, tag and publish the + same way as 4.4.0, without the advisory steps. Close PR #557 and the issues Phase 12 fixed. + Done 2026-11-10 (PR #642, released three days into the 4.4.0 soak with no new issues); #545 + and #541 closed, #353 left open for 5.0. +4. **Soak 4.5.0 for a day or two** (decided 2026-11-10: 4.4.0 drew no issues, comments or + regressions in its first three days). Release 4.6.0 once 4.5.0 shows no engagement either. +5. **4.6.0** (Phase 13). `npm test` on `phase-13` runs `suite-webkit`, so the release `verify` job + now installs `chromium webkit` with `--with-deps`, as `ci.yml` does. Push `phase-13`; its + Firefox, WebKit and end-to-end CI jobs run for the first time. Rehearse `release.yml` with + `workflow_dispatch` on the branch before tagging, then release the same way as 4.5.0. + - `phase-13` renames the matrix checks to `jQuery on `, so the required checks + on `main` (`jQuery 1.7.2`, `jQuery 3.7.1`, `jQuery 4.0.0`) never report and the PR stays + blocked. Update branch protection to the new names (or a subset, such as the Chromium ones) + when the PR's first run shows them. + - Done 2026-11-14: `main` requires `test` and the nine `jQuery on ` checks. + The end-to-end checks stay optional until they have a few weeks of clean runs (about + 2026-12-05); then add the nine `e2e on jQuery on ` checks too. + - `ubuntu-latest` moved to 26.04 on 2026-11-14 and the Playwright cache restored a 24.04 WebKit + that could not load its libraries. The cache keys now include the runner image (`ImageOS`). +6. **5.0** (Phase 14) after 4.6.0. Cut `release/4.x` from the 4.6.0 tag first (ADR-0002). + +Each release adds its column to `docs/metrics.md` and its section to the GitHub release notes. ## Phase 12: 4.x cleanup and rearchitecture (no breaking change) @@ -378,7 +461,8 @@ slice is done (`src/submitter.js`; controls named `clk`, `SubmitEvent.submitter` GET uploads). The ajaxForm binding slice is done (`src/ajax-form.js`, `delegation: ""`, `ajaxFormUnbind(selector)`, the `delegation: true` warning). The deprecation warnings, the `target` sanitizing, trusted-options and iframe-response docs, and the remaining fixes (D-12, D-13, -D-15, D-19, D-25, the FormData `beforeSend` veto) are done; IFR-122/123 stay `it.fails` for 5.0. +D-15, D-19, D-25, the FormData `beforeSend` veto) are done; IFR-122/123 were left `it.fails` and +are fixed in Phase 13. Phase 12 shipped as 4.5.0 on 2026-11-10 (PR #642), three days into the 4.4.0 soak with no new issues. CodeQL alert 10 (the `target` lookup, moved by the module split) was dismissed as "won't fix"; 4.6.0 removes the lookup. The custom CodeQL canary flagged every reopened W1–W4 sink. @@ -408,8 +492,14 @@ looked like a bug. ## Phase 13: 4.x test hardening (no breaking change) The Phase 12 sweep found about 70 bugs that 100% coverage had not caught. This phase adds kinds of -tests the suite does not have yet, so that 5.0 starts from a stronger contract. It runs on the same -local branch as Phase 12. +tests the suite does not have yet, so that 5.0 starts from a stronger contract. It runs on the local +`phase-13` branch, which starts after the 4.5.0 cut on `phase-12`. + +Status: done, and in the 4.6.0 release PR (#644, branch `release-4.6.0`). All five kinds of tests +are in place and pass on Chromium, WebKit and Firefox with jQuery 1.7.2, 3.7.1 and 4.0.0; no +`it.fails` remain. The mutation score went from 91.67% to 94.34%. The new WebKit, Firefox and +end-to-end CI jobs ran for the first time on the PR and pass. The `release.yml` rehearsal on the +branch passed on 2026-11-14 (run 43600588779), and the version bump is in. - Run the suite on Firefox and WebKit as well as Chromium (Vitest browser instances), locally and in CI. @@ -426,6 +516,86 @@ local branch as Phase 12. entry in `docs/research/4x-behavior-changes.md`; otherwise it is reported as a bug or an undocumented change. +Fixes in 4.6.0 (each in `docs/research/4x-behavior-changes.md`, Phase 13): + +- Lone surrogates become U+FFFD instead of throwing `URIError`: in form fields (`formSerialize`, + `fieldSerialize`, urlencoded bodies, the iframe submitter), and in `data` and `extraData` keys and + values on every transport. +- Spaces encode as `+` on every jQuery version. +- An iframe response that cannot be parsed rejects with `parsererror`, and an error status that + also fails to parse reports its `statusText` (IFR-122/123, the last `it.fails`). +- The iframe upload leaves out a clicked button disabled by its fieldset. +- Packaging: no `browser` field (bundlers get the module build; `jsdelivr` and `unpkg` name the + minified build), `LICENSE-MIT` published, and the CommonJS factory uses the window it is given. +- Docs: a Deprecations section in `docs/api.md` listing each warning and its replacement. +- `target` and `iframeTarget` strings are only selectors (`$(document).find()`), never parsed as + HTML. Decided on 2026-11-08: alert 7 had been dismissed as "won't fix" under finding 11, but + unlike `url` or `iframeSrc` this risk is not inherent, and the fix keeps every selector's result. + It goes in 4.6.0, not 4.5.0, in case a consumer relied on an HTML string. Closes CodeQL alert 10, + the alert 7 lookup reopened by the 4.5.0 module split (it shows on PR #642). +- Dev only (not in the published package): an npm `overrides` entry pins `minimatch` to 11.0.4 + for Dependabot alert 97 (CVE-2026-118764, through eslint, which still requires `minimatch@^10` + and has no patched 10.x). Remove the override once eslint allows minimatch 11. The same commit + went to `main` early in PR #638, after Dependabot reopened the alert there as alert 98; the + `phase-13` rebase drops its copy as already applied. + +Docs, README and repository cleanup, with 4.6.0. Decided on 2026-11-10. Everything lands as +commits on `phase-13` and ships in the 4.6.0 PR, so the stacked branches rebase once. Only the +`package.json` items change the published package. + +README (a landing page; the docs site is the one reference): + +- Cut the API, Options and Utility Methods sections and link to the docs site pages instead. + Keep overview, installation, quick start, compatibility, security, contributing and license. +- Add Installation and Usage: `npm install jquery-form`, the module import (it registers the + plugin and needs jQuery importable), the CommonJS `(root, jQuery)` factory, and a script tag + after jQuery. +- Point Download at npm, the CDN and the release tag, not at `dist/` on `main`, which will hold + 5.0 code once Phase 14 lands. +- Rewrite File Uploads (it says "As of today (March 2012)"): FormData by default, `iframe: true` + as the fallback, and fix its XMLHttpRequest Level 2 link (the URL is wrapped in quotes). +- Compatibility: name the tested browsers (Chromium, Firefox and WebKit), and say that 5.0 will + need jQuery 3.5 or later, linking #629. +- Add a cdnjs snippet back as the alternative to jsDelivr, once cdnjs serves the current version. + Check its sha384 against the published `dist/jquery.form.min.js` first. +- Switch `http://` links that have an `https://` version. +- Bump the CDN snippets in `README.md` and `docs/index.md` to 4.6.0 with the new SRI hash. + +Docs site: + +- `docs/_layouts/default.html`: remove the html5shiv script (its Google Code URL is a 404), the + IE conditional comment, the `X-UA-Compatible: chrome=1` meta (Chrome Frame), and the Universal + Analytics block, which never renders because `_config.yml` sets no `google_analytics`. +- `docs/index.md`: add npm installation to the Quick Start, next to the CDN snippet. +- `docs/faq.md`: point "Run unit tests" at `CONTRIBUTING.md` instead of the 3.x test page on + malsup.com, and replace the `view-source:` progress demo link. +- Checked every malsup.com link on 2026-11-10. All serve content except + `jquery.malsup.com/form/` (an empty page; `CONTRIBUTORS.md` now links `malsup.com/jquery/form/`). + The FAQ comparison and code-sample links and the examples' progress demos point at the docs + site instead; the demo endpoints stay, over https, until the 5.0 examples rewrite. + +Package metadata (in the 4.6.0 package): + +- `license`: `(LGPL-2.1-or-later OR MIT)` instead of the deprecated SPDX `LGPL-2.1+`; the same in + `bower.json`, `composer.json` and `form.jquery.json`. Same terms. +- `homepage`: the docs site, https://jquery-form.github.io/form/. + +Repository: + +- Replace `.github/issue_template.md` (it asks for a "LoadJSON" version) with an issue form that + asks for the plugin, jQuery and browser versions, and a `config.yml` that sends security + reports to `SECURITY.md`. +- Add `.github/dependabot.yml` version updates for GitHub Actions and grouped npm dev + dependencies (only alerts are on today). +- Keep `CODE_OF_CONDUCT.md` at Contributor Covenant 1.4 (decided 2026-11-10, reversing the 2.1 + update planned the same day). 2.1 needs a private reporting contact, the project has no email + address, and GitHub has no private conduct channel to maintainers: private vulnerability + reporting is for security issues, and "Report content" goes to GitHub, not to the maintainer. + Revisit if the project gets a contact address. +- Delete the root `_config.yml`; Pages builds from `/docs`. Fix the broken headings in + `CONTRIBUTORS.md`. +- Close #544 at the release: both items it lists are resolved, and #353 tracks the rest. + Release Phase 13 as 4.6.0, the same way as 4.5.0. Fixes found here go in 4.6.0, not 4.5.0. Cut `release/4.x` when 5.0 lands (ADR-0002). ## Phase 14: 5.0 (breaking) @@ -445,6 +615,32 @@ Release Phase 13 as 4.6.0, the same way as 4.5.0. Fixes found here go in 4.6.0, keep-alive workaround). `enable` and `selected` are kept. - Move to ES2015+ syntax and revisit Prettier `trailingComma`. - Decide whether `formToArray` and the other serializers keep calling an overridable `$.fieldValue`, or use the internal successful-controls module (5.0). +- Found by the Phase 13 end-to-end tests, left as they are in 4.x: + - An empty file input goes through the FormData upload as an empty text field. A native submit + sends an empty file part (filename "", `application/octet-stream`), so servers see a form field + instead of an empty upload (PHP `$_POST` instead of `$_FILES`). + - The iframe upload adds the clicked button's fields after the form's own, where a native + submit sends them in tree order. +- Found by the Phase 13 serialization oracle (spec gaps against `new FormData(form)`), left as they + are in 4.x: + - `dirname` fields (`name=ltr`) are never sent. + - A hidden `_charset_` input sends its own value instead of the encoding (`UTF-8`). + - A clicked `` without a `value` sends `""` instead of the browser's default + label ("Submit", or "Submit Query" in Firefox). + - A clicked image sends its `name=value` before `name.x`/`name.y`; native sends only the + coordinates. + - An unnamed clicked image sends nothing; native sends `x` and `y`. +- Docs examples and FAQ for 5.0: + - `docs/examples.md` posts to Mike Alsup's demo scripts on malsup.com (`dummy.php`, + `json-echo.php` and others) and loads `submit.gif` from there. Replace them + with examples that need no third-party server, or document the expected response instead. + - Rewrite the examples for the 5.0 API: jQuery 3.5 or later, `delegation: ""`, + `iframe: true` for uploads without `FormData`, and no deprecated methods. + - Replace the retired `docs.jquery.com/Plugins` link in the examples. 4.6.0 replaces every + malsup.com documentation link (FAQ comparison, unit tests, code samples, progress demos) with + the docs site's own pages, and loads the demo endpoints over https until this rewrite. + - README: the pointer to malsup.com docs for 3.51 and older, and the jQuery 4 compatibility + notes, which change with the peer dependency. - Serialize in native order (D-17): `form=` controls in tree order rather than appended last, and semantic mode limited to submittable elements. 4.x keeps the current order. ## 5.x diff --git a/docs/research/4x-behavior-changes.md b/docs/research/4x-behavior-changes.md index 75a01b74..9e2b13fc 100644 --- a/docs/research/4x-behavior-changes.md +++ b/docs/research/4x-behavior-changes.md @@ -50,7 +50,7 @@ Collected as the modernization proceeds. Each entry is a change a consumer could - **A string `data` option is a query string.** It is appended as-is to a urlencoded body or GET url, and split into its own fields for FormData and iframe uploads. It used to be sent one character at a time (`0=x&1=%3D&2=1`), and an iframe upload with a clicked submitter or the CSRF metas threw. - **`ajaxSubmit` on jQuery's slim build throws a clear error (#541).** The slim builds have no `$.ajax`. `ajaxSubmit` now throws `jquery.form: ajaxSubmit needs the full jQuery build; this jQuery has no $.ajax` before any event or callback, instead of a `TypeError` about `success`. An empty selection still returns silently. - **New option `requestFormat: "json"` (#545).** It sends the fields (repeated names as arrays) merged with object `data` as a JSON body with `contentType: "application/json; charset=UTF-8"`. It throws a clear error on a GET method, with string `data`, with files or a multipart form, and with the iframe transport. Based on the idea in PR #557 by zhangciwu. -- **The iframe upload fires its events in `$.ajax` order.** `ajaxSend` now fires after `beforeSend`, and not at all when `beforeSend` returns `false` or aborts. A `beforeSend` veto rejects the Deferred and fires `ajaxError` (`"canceled"`), `ajaxComplete` and `ajaxStop`, so `$.active` drops back and global spinners stop; it used to fire `ajaxSend` and leave the global events open. The `complete` callback runs before `ajaxComplete` and `ajaxStop` (it ran after them), and `ajaxSuccess` handlers receive the parsed data as their fourth argument. Unchanged until 5.0: `.done` receives the response text, and a parse error rejects with `"error"`. +- **The iframe upload fires its events in `$.ajax` order.** `ajaxSend` now fires after `beforeSend`, and not at all when `beforeSend` returns `false` or aborts. A `beforeSend` veto rejects the Deferred and fires `ajaxError` (`"canceled"`), `ajaxComplete` and `ajaxStop`, so `$.active` drops back and global spinners stop; it used to fire `ajaxSend` and leave the global events open. The `complete` callback runs before `ajaxComplete` and `ajaxStop` (it ran after them), and `ajaxSuccess` handlers receive the parsed data as their fourth argument. Unchanged until 5.0: `.done` receives the response text. A parse error rejected with `"error"` until 4.6.0 (see Phase 13). - **Every iframe upload settles once, also when it fails with an exception.** An `iframeTarget` that matches nothing, or a subject that is not a form, used to throw and leave `$.active` raised with no `ajaxStop`. The upload now settles with `"error"` and the exception: the `error` callback, a rejected Deferred, `ajaxError`, `complete`, `ajaxComplete` and `ajaxStop`. A `success` callback that throws no longer leaves the Deferred pending and the global events open; its exception still reaches the console, after the upload settled. `beforeSend` that aborts and returns `false` no longer decrements `$.active` twice. @@ -112,6 +112,19 @@ Collected as the modernization proceeds. Each entry is a change a consumer could - **Deprecation warnings under `debug`.** With `$.fn.ajaxSubmit.debug = true`, the plugin logs one `console.warn` per page for each feature 5.0 removes: `clearInputs` (use `clearFields`), `$.fn.attr2` (use `.prop()` or `.attr()`), `ajaxForm` queued until the DOM is ready on an empty selection (call it inside `$(fn)` or use `delegation: ""`), the iframe transport chosen automatically without `FormData` (set `iframe: true`), and jQuery before 3.5 (5.0 needs 3.5 or later). Nothing is logged with `debug` off. `clearInputs` is now a separate function that calls `clearFields`. `enable` and `selected` are kept. +## Phase 13 + +- **A lone surrogate is sent as U+FFFD.** `formSerialize`, `fieldSerialize`, a urlencoded `ajaxSubmit` body and the clicked button of an iframe upload threw `URIError` when a name or value held an unpaired UTF-16 surrogate. Each one is now replaced with U+FFFD, as a native form submission and `FormData` do. +- **Bundlers get the module build; CDNs keep the minified one.** The `browser` field in `package.json` pointed at `dist/jquery.form.min.js`, and bundlers that read it first (webpack, Vite, Browserify) bundled the minified classic build. It is removed: webpack and Vite now use `module` (`dist/jquery.form.mjs`) and Browserify uses `main` (`dist/jquery.form.js`). New `jsdelivr` and `unpkg` fields keep a bare CDN URL serving `dist/jquery.form.min.js`. +- **The package includes `LICENSE-MIT`.** The package is dual-licensed (LGPL-2.1+ or MIT), but only `LICENSE` was published. +- **The CommonJS factory uses the window it is given.** `require("jquery-form")(root, $)` read the global `window` and `document`, so it threw in Node unless a DOM was global (as in jest-environment-jsdom). The classic build now takes `window`, `document`, `navigator`, `Element` and `FormData` from `root`, falling back to the global window. jQuery 4 itself still needs a global window when required without one. +- **Spaces encode as `+` on every jQuery version.** jQuery 3 and later made `$.param` write a space as `%20`, so `formSerialize`, `fieldSerialize`, a GET query string and the `data` that `beforeSend` sees used `%20`, while jQuery 1 and 2 and a native form submission use `+`. They now use `+` everywhere. Servers decode both the same way; only code that compares the strings sees a difference. A string `data` option is passed through unchanged. +- **An iframe response that cannot be parsed rejects with `parsererror`.** The Deferred of an iframe upload rejected with `"error"` when the response did not parse for the `dataType`, while `error`, `complete` and an XHR request report `"parsererror"`; it now rejects with `"parsererror"` too. When the response also carries an emulated error status (a `status` attribute outside 2xx), `error`, `ajaxError` and the rejection now receive the `statusText` attribute, as `$.ajax` reports a server error, instead of the parse exception; the status stays `"error"`. +- **An iframe upload no longer sends a button disabled by its fieldset.** The clicked button (from a click, `form.clk` or `requestSubmit(button)`) was added to an iframe upload when a disabled `
` disabled it; only its own `disabled` was checked. It is now left out, as the XHR transports and a native submission do. A button in the first `` of a disabled fieldset is still sent. The submitter's fields still come after the form's own. +- **A lone surrogate in `data` or `extraData` is sent as U+FFFD.** An object `data` option or `extraData` whose keys or string values (nested objects and arrays and the `{ name, value }` form included) held an unpaired UTF-16 surrogate made `ajaxSubmit` throw `URIError` on every transport. Each one is now replaced with U+FFFD, as for form fields above. A string `data` option is passed through unchanged. +- **Replacing `$.fieldValue` warns under debug.** `formToArray`, `formSerialize`, `fieldSerialize` and `ajaxSubmit` read values through `$.fieldValue` at call time, so a page that replaced it changed what was sent. That still works, but with `$.fn.ajaxSubmit.debug` on, the first serialization through a replacement warns once per page that 5.0 drops it and to use jQuery `valHooks`. `$.fn.fieldValue` reads through the replacement without warning. +- **`target` and `iframeTarget` strings are only selectors.** Both were passed to `$()`, which builds elements from a string that looks like HTML (on jQuery 1.9 and later one that starts with `<`; on 1.7.2 one that holds a tag anywhere, such as `div[title=""]`), running any inline handlers in it. A string is now looked up with `$(document).find()`: a selector finds the same elements as before, a string starting with `<` matches nothing (with a `debug` log), and on 1.7.2 a selector with a tag in an attribute value works. Elements and jQuery objects are used as given. An HTML `target` used to receive the response in a detached element; `success` still runs, with the settings as `this`. An HTML `iframeTarget` already failed in 4.5.0. This fixes CodeQL `js/unsafe-jquery-plugin` (alerts 7 and 10; finding 11 in `security-review.md`). + ## Known behavior, not changed - **`dataType: "script"` on jQuery 4** delivers `undefined` to `success`; jQuery 4 loads async script requests through a script tag. The script still runs. This comes from jQuery, not the plugin. diff --git a/docs/research/security-review.md b/docs/research/security-review.md index 49b14a05..1f4be917 100644 --- a/docs/research/security-review.md +++ b/docs/research/security-review.md @@ -193,7 +193,7 @@ With `semantic`, `formToArray` walks `getElementsByTagName("*")` (line 1114). Th ### 11. Options that must be trusted -- **`url`, a form's `action`, `iframeSrc`, `closeKeepAlive`, `target` and `iframeTarget` are developer input.** A `javascript:` URL in `url` or `action` runs when the iframe transport submits. That is the same as a native submit. Selector options passed to `$()` are parsed as HTML on jQuery < 1.9 if they contain a tag. +- **`url`, a form's `action`, `iframeSrc`, `closeKeepAlive`, `target` and `iframeTarget` are developer input.** A `javascript:` URL in `url` or `action` runs when the iframe transport submits. That is the same as a native submit. Selector options passed to `$()` were parsed as HTML: on jQuery < 1.9 if they contain a tag, and on every version if they start with `<`. Since 4.6.0, `target` and `iframeTarget` strings are looked up with `$(document).find()` and are never parsed as HTML; they stay trusted because they choose where the response goes. - **No `document.domain` handling remains.** A cross-origin response fails closed: `getDoc` throws, and the transport reports a server abort (lines 644–661). - **Docs.** List these options as trusted-only in `docs/options.md`. @@ -214,7 +214,7 @@ With `semantic`, `formToArray` walks `getElementsByTagName("*")` (line 1114). Th **What it finds.** On `main`, the built-in queries report three alerts in `src/`: - `js/html-constructed-from-input` on the two lines #604 reported. -- `js/unsafe-jquery-plugin` on the `iframeTarget` lookup, which is a developer-supplied selector (finding 11). +- `js/unsafe-jquery-plugin` on the `iframeTarget` lookup, which is a developer-supplied selector (finding 11). Dismissed as alert 7 for 4.4.0; the 4.5.0 module split reopened it as alert 10. Fixed in 4.6.0, which looks selector strings up with `.find()`. Most of W1–W4 were not flagged by the built-in queries; the custom pack (see Detection above) covers them, and the tests pin the fixes. @@ -244,7 +244,7 @@ The ADR-0001 dual surface (a module entry plus the classic script-tag, AMD and C } ``` -- **`main`, `module` and `browser` stay** for tools that predate `exports`. +- **`main` and `module` stay** for tools that predate `exports`, and `jsdelivr`/`unpkg` keep naming the minified build for CDNs. 4.6.0 dropped `browser`. - **Script tags and AMD are unaffected**, because they load files by path (CDNs, `bower.json`, `composer.json`). `test/surfaces/manifests.test.js` gains checks that every 4.x deep path still resolves through `exports`. - **Dual-package hazard.** An app that both `import`s and `require`s the plugin loads it twice. The module registers on import; the CommonJS factory registers when it is called with a jQuery. If both get the same jQuery, the only cost is registering twice. If they get different jQuery copies, each copy gets its own plugin. Document it rather than work around it; the peer dependency (finding 5) makes a single jQuery the normal case. diff --git a/docs/research/tooling-research.md b/docs/research/tooling-research.md index 48689871..ee103b1f 100644 --- a/docs/research/tooling-research.md +++ b/docs/research/tooling-research.md @@ -127,7 +127,7 @@ Line numbers from current `src/jquery.form.js` (1540 lines). Best option for 100 | 688-690 | `io.attachEvent` (IE<9) vs `addEventListener` | dead branch | remove | | 751-800 | iframe response handling: `doc.XMLDocument`, Opera retry (775-785), `xhr.responseXML = doc.XMLDocument ?...` (771, 793) | IE/Opera only | remove Opera/XMLDocument parts | | 914-918 | `window.ActiveXObject` / `Microsoft.XMLDOM` for `toXml` | IE only | use `DOMParser` | -| 925-928 | `$.parseJSON | | ` fallback | dead on 4, jQuery 3 has it | `JSON.parse` | +| 925-928 | `$.parseJSON \|\|` fallback | dead on 4, jQuery 3 has it | `JSON.parse` | | 1115 | `/(Edge\|Trident)\//.test(navigator.userAgent)` in `formToArray` form-attribute handling | legacy Edge/IE UA | remove; verify `form=` attribute works in modern browsers | | 1157 | `feature.fileapi && el.type === 'file'` | always true | simplify | | 1379 | `/MSIE/.test(navigator.userAgent)` in `clearFields` file input (clone/replace) | IE only | `$(this).val('')` | diff --git a/eslint.config.mjs b/eslint.config.mjs index 3059bb50..19ca70db 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -78,7 +78,17 @@ const sourceRules = { }; export default [ - { ignores: [".jquery/**", "dist/**", "coverage/**", "test/ajax/**"] }, + { + ignores: [ + ".jquery/**", + "dist/**", + "coverage/**", + "test/ajax/**", + "test-results/**", + "playwright-report/**", + ".pack/**", + ], + }, js.configs.recommended, { files: ["src/**/*.js"], @@ -96,6 +106,19 @@ export default [ globals: { ...globals.browser, $: "readonly", jQuery: "readonly" }, }, }, + { + files: ["test/shared/**/*.js", "test/e2e/harness.js"], + languageOptions: { sourceType: "module", globals: globals.browser }, + }, + { + files: ["test/e2e/published.js"], + languageOptions: { sourceType: "script", globals: globals.browser }, + }, + { + // Node files whose page.evaluate callbacks run in the browser. + files: ["test/e2e/**/*.mjs"], + languageOptions: { globals: { ...globals.node, ...globals.browser } }, + }, { files: ["test/setup.js", "test/surfaces/browser.test.js"], languageOptions: { globals: globals.browser }, diff --git a/form.jquery.json b/form.jquery.json index 3cf77b00..4a65effc 100644 --- a/form.jquery.json +++ b/form.jquery.json @@ -1,7 +1,7 @@ { "name": "form", "title": "jQuery Form", - "version": "4.5.0", + "version": "4.6.0", "author": { "name": "Kevin Morris", "url": "https://github.com/kevindb/" @@ -17,12 +17,12 @@ "form", "jquery-form" ], - "homepage": "https://github.com/jquery-form/form", + "homepage": "https://jquery-form.github.io/form/", "docs": "https://jquery-form.github.io/form/", "bugs": "https://github.com/jquery-form/form/issues", "licenses": [ { - "type": "LGPL-2.1+", + "type": "LGPL-2.1-or-later", "url": "https://github.com/jquery-form/form/blob/main/LICENSE" }, { diff --git a/package-lock.json b/package-lock.json index db5727b5..67b45a20 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,18 +1,19 @@ { "name": "jquery-form", - "version": "4.5.0", + "version": "4.6.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "jquery-form", - "version": "4.5.0", - "license": "(LGPL-2.1+ OR MIT)", + "version": "4.6.0", + "license": "(LGPL-2.1-or-later OR MIT)", "dependencies": { "jquery": ">=1.7.2" }, "devDependencies": { "@eslint/js": "10.0.1", + "@playwright/test": "1.64.1", "@rollup/plugin-terser": "1.0.2", "@vitest/browser-playwright": "5.0.5", "@vitest/coverage-v8": "5.0.5", @@ -21,6 +22,7 @@ "globals": "17.13.0", "jquery": "3.7.1", "jquery4": "npm:jquery@4.0.0", + "jsdom": "30.1.3", "magic-string": "1.4.3", "playwright": "1.64.1", "prettier": "3.9.10", @@ -29,6 +31,39 @@ "vitest": "5.0.5" } }, + "node_modules/@asamuzakjp/css-color": { + "version": "7.1.9", + "resolved": "https://registry.npmjs.org/@asamuzakjp/css-color/-/css-color-7.1.9.tgz", + "integrity": "sha512-vZ6JQVq8Ivgz6b/IBlAf90wZviXdluY13cQOPO+nJHbmXwGrPl2GcpqUY7a55/8ZVdfONXpCFMpRijOBCHNlcQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@csstools/css-calc": "^3.4.3", + "@csstools/css-color-parser": "^4.2.6", + "@csstools/css-parser-algorithms": "^4.0.2", + "@csstools/css-tokenizer": "^4.0.2", + "lru-cache": "^11.5.3" + }, + "engines": { + "node": "^22.22.2 || ^24.15.0 || >=26.0.0" + } + }, + "node_modules/@asamuzakjp/dom-selector": { + "version": "10.0.5", + "resolved": "https://registry.npmjs.org/@asamuzakjp/dom-selector/-/dom-selector-10.0.5.tgz", + "integrity": "sha512-EgmJ7oEaGQECTn3H3wmnQpEy4hKY66VvM7VQndwPIQob3p877BgbyOUE3EX0LgXQCciF2H8KMdR+RznqjMNOLw==", + "dev": true, + "license": "MIT", + "dependencies": { + "bidi-js": "^1.1.0", + "css-tree": "^3.2.1", + "is-potential-custom-element-name": "^1.0.1", + "lru-cache": "^11.5.3" + }, + "engines": { + "node": "^22.22.2 || ^24.15.0 || >=26.0.0" + } + }, "node_modules/@babel/helper-string-parser": { "version": "7.29.11", "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.29.11.tgz", @@ -96,6 +131,19 @@ "dev": true, "license": "MIT" }, + "node_modules/@bramus/specificity": { + "version": "2.4.3", + "resolved": "https://registry.npmjs.org/@bramus/specificity/-/specificity-2.4.3.tgz", + "integrity": "sha512-0GEz8qJWokkUVYQYRukmkSHIFNoBH8QTreeHrAFbvz1XFYc3Y+puhMs8PQ5x8GNugiC2l5jvDBXKLbBIByeSBw==", + "dev": true, + "license": "MIT", + "dependencies": { + "css-tree": "^3.2.1" + }, + "bin": { + "specificity": "bin/cli.js" + } + }, "node_modules/@cacheable/memory": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/@cacheable/memory/-/memory-2.2.0.tgz", @@ -120,6 +168,146 @@ "keyv": "^5.6.0" } }, + "node_modules/@csstools/color-helpers": { + "version": "6.1.2", + "resolved": "https://registry.npmjs.org/@csstools/color-helpers/-/color-helpers-6.1.2.tgz", + "integrity": "sha512-grhRy3OKmniaAEKXMjua5z/EODX0MSqBGjunw8+j/3HQjOnahs2AGhvEOIYVUWcU6ScApbhLhVrQTX8XqrMrow==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "license": "MIT-0", + "engines": { + "node": ">=20.19.0" + } + }, + "node_modules/@csstools/css-calc": { + "version": "3.4.3", + "resolved": "https://registry.npmjs.org/@csstools/css-calc/-/css-calc-3.4.3.tgz", + "integrity": "sha512-iex20d8CHVkyvg6B7UKV7uHnI2Bqo9g+EFfT9E0y+GvTvhZ/DwONJ+9aKb1dlqm0ZiGsL5RXjp0fCoJYnkeDjA==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "license": "MIT", + "engines": { + "node": ">=20.19.0" + }, + "peerDependencies": { + "@csstools/css-parser-algorithms": "^4.0.2", + "@csstools/css-tokenizer": "^4.0.2" + } + }, + "node_modules/@csstools/css-color-parser": { + "version": "4.2.7", + "resolved": "https://registry.npmjs.org/@csstools/css-color-parser/-/css-color-parser-4.2.7.tgz", + "integrity": "sha512-zgm9yjQz5iJB4VL8RyVwd71TWB8Q89FSxt/NzXoWqPSkEBOVtn9L6vAPtSc9hpKfB0Awo/AL2VKFHjYetBLFHQ==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "license": "MIT", + "dependencies": { + "@csstools/color-helpers": "^6.1.2", + "@csstools/css-calc": "^3.4.3" + }, + "engines": { + "node": ">=20.19.0" + }, + "peerDependencies": { + "@csstools/css-parser-algorithms": "^4.0.2", + "@csstools/css-tokenizer": "^4.0.2" + } + }, + "node_modules/@csstools/css-parser-algorithms": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/@csstools/css-parser-algorithms/-/css-parser-algorithms-4.0.2.tgz", + "integrity": "sha512-40cSKyMvK+tq4qz6Awrlye2WGuOKt3FwPgtGg6KTfbHOWNw+Rk1rzbAtZnZ6IBhsY491HLRnDXwoyBAijmmILA==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "license": "MIT", + "engines": { + "node": ">=20.19.0" + }, + "peerDependencies": { + "@csstools/css-tokenizer": "^4.0.2" + } + }, + "node_modules/@csstools/css-syntax-patches-for-csstree": { + "version": "1.1.16", + "resolved": "https://registry.npmjs.org/@csstools/css-syntax-patches-for-csstree/-/css-syntax-patches-for-csstree-1.1.16.tgz", + "integrity": "sha512-LsDbJPP/B8cPasUJyTA5S99F7C4G93ngW8hUluXz8CFeOaaRnBPtBiIlvgcPYU0HmHNz8CXg+1vwFrIB4F6Dgw==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "license": "MIT-0", + "peerDependencies": { + "css-tree": "^3.2.1" + }, + "peerDependenciesMeta": { + "css-tree": { + "optional": true + } + } + }, + "node_modules/@csstools/css-tokenizer": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/@csstools/css-tokenizer/-/css-tokenizer-4.0.2.tgz", + "integrity": "sha512-OoKoR0f76dCY666JlcbhmVTs2drYj1GUXZTYTcbUgJjh9Nv41aFfZ21bPQTERm5+L5cBDo466NltB2lplS5GBw==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/csstools" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/csstools" + } + ], + "license": "MIT", + "engines": { + "node": ">=20.19.0" + } + }, "node_modules/@eslint-community/eslint-utils": { "version": "4.10.1", "resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.10.1.tgz", @@ -248,6 +436,24 @@ "node": "^20.19.0 || ^22.13.0 || >=24" } }, + "node_modules/@exodus/bytes": { + "version": "1.16.0", + "resolved": "https://registry.npmjs.org/@exodus/bytes/-/bytes-1.16.0.tgz", + "integrity": "sha512-IcpW84uEn3N7ETtNZMlxKhfl6Pec8rUNGOTBtWbK1FKhJxIFAptZyVrvVRVBimAJxJCgc3PxepxkdWWG4DVzfA==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^20.19.0 || ^22.12.0 || >=24.0.0" + }, + "peerDependencies": { + "@noble/hashes": "^1.8.0 || ^2.0.0" + }, + "peerDependenciesMeta": { + "@noble/hashes": { + "optional": true + } + } + }, "node_modules/@humanfs/core": { "version": "0.19.2", "resolved": "https://registry.npmjs.org/@humanfs/core/-/core-0.19.2.tgz", @@ -426,6 +632,22 @@ "url": "https://github.com/sponsors/oxc-project" } }, + "node_modules/@playwright/test": { + "version": "1.64.1", + "resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.64.1.tgz", + "integrity": "sha512-IaYGml/nSOiZWROfPtuIL7neuu9qDOZ3TNvNljUIrhDMxiGTgPjzj/g9p9RxpS2tSepPDRY+UwAaEeiKtUvIAg==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "playwright": "1.64.1" + }, + "bin": { + "playwright": "cli.js" + }, + "engines": { + "node": ">=20" + } + }, "node_modules/@polka/url": { "version": "1.0.0-next.29", "resolved": "https://registry.npmjs.org/@polka/url/-/url-1.0.0-next.29.tgz", @@ -1439,6 +1661,16 @@ "node": "18 || 20 || >=22" } }, + "node_modules/bidi-js": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/bidi-js/-/bidi-js-1.1.0.tgz", + "integrity": "sha512-fX1Onk0tdVPC7obPWB5EbJ1z7NVhLq4m2xZLq2YXBkxzMXIGRpNMU88n0EPgWseKl12J7zXs7qrDxPK4sRs2fg==", + "dev": true, + "license": "MIT", + "dependencies": { + "require-from-string": "^2.0.2" + } + }, "node_modules/brace-expansion": { "version": "5.0.12", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.12.tgz", @@ -1512,6 +1744,34 @@ "node": ">= 8" } }, + "node_modules/css-tree": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/css-tree/-/css-tree-3.2.1.tgz", + "integrity": "sha512-X7sjQzceUhu1u7Y/ylrRZFU2FS6LRiFVp6rKLPg23y3x3c3DOKAwuXGDp+PAGjh6CSnCjYeAul8pcT8bAl+lSA==", + "dev": true, + "license": "MIT", + "dependencies": { + "mdn-data": "2.27.1", + "source-map-js": "^1.2.1" + }, + "engines": { + "node": "^10 || ^12.20.0 || ^14.13.0 || >=15.0.0" + } + }, + "node_modules/data-urls": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/data-urls/-/data-urls-8.0.0.tgz", + "integrity": "sha512-JQUCCK+/CAGbGGx618PlFZMXH81Jtj7t73CHv9dd/zVWvxgGT2zLFRjnKb+Ng46GIwcy+f7f88qd4duqllK+WQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "whatwg-mimetype": "^5.0.0", + "whatwg-url": "^17.1.2" + }, + "engines": { + "node": "^22.14.0 || >=24.0.0" + } + }, "node_modules/debug": { "version": "4.4.3", "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz", @@ -1530,6 +1790,13 @@ } } }, + "node_modules/decimal.js": { + "version": "10.6.0", + "resolved": "https://registry.npmjs.org/decimal.js/-/decimal.js-10.6.0.tgz", + "integrity": "sha512-YpgQiITW3JXGntzdUmyUR1V812Hn8T1YVXhCu+wO3OpS4eU9l4YdD3qjyiKdV6mvV29zapkMeD390UVEf2lkUg==", + "dev": true, + "license": "MIT" + }, "node_modules/deep-is": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.4.tgz", @@ -1548,6 +1815,19 @@ "node": ">=8" } }, + "node_modules/entities": { + "version": "9.0.0", + "resolved": "https://registry.npmjs.org/entities/-/entities-9.0.0.tgz", + "integrity": "sha512-oJFNDJg3kTPwAD1cNn2+WmUq4wFoo09npc3Ydf1D7ED4smRiWrsKnaLxykrTWgyGEcusc87P5dxlAleol9kpkg==", + "dev": true, + "license": "BSD-2-Clause", + "engines": { + "node": ">=20.19.0" + }, + "funding": { + "url": "https://github.com/fb55/entities?sponsor=1" + } + }, "node_modules/es-module-lexer": { "version": "2.3.2", "resolved": "https://registry.npmjs.org/es-module-lexer/-/es-module-lexer-2.3.2.tgz", @@ -1912,6 +2192,19 @@ "dev": true, "license": "MIT" }, + "node_modules/html-encoding-sniffer": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/html-encoding-sniffer/-/html-encoding-sniffer-7.0.0.tgz", + "integrity": "sha512-UikN5yr7xsCDAq87Or5or0PAlD3HJJOKVzM05az588WnpDJ4Ux7a2A53Qi6gofGg2/EtvF/H4hCi/TXfCW4Y6w==", + "dev": true, + "license": "MIT", + "dependencies": { + "@exodus/bytes": "^1.15.1" + }, + "engines": { + "node": "^22.13.0 || >=24.0.0" + } + }, "node_modules/ignore": { "version": "5.3.2", "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.3.2.tgz", @@ -1955,6 +2248,13 @@ "node": ">=0.10.0" } }, + "node_modules/is-potential-custom-element-name": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-potential-custom-element-name/-/is-potential-custom-element-name-1.0.1.tgz", + "integrity": "sha512-bCYeRA2rVibKZd+s2625gGnGF/t7DSqDs4dP7CrLA1m7jKWz6pps0LpYLJN8Q64HtmPKJ1hrN3nzPNKFEKOUiQ==", + "dev": true, + "license": "MIT" + }, "node_modules/isexe": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", @@ -1984,6 +2284,46 @@ "dev": true, "license": "MIT" }, + "node_modules/jsdom": { + "version": "30.1.3", + "resolved": "https://registry.npmjs.org/jsdom/-/jsdom-30.1.3.tgz", + "integrity": "sha512-hQMUPvRgN7KxsfIytDQji7bimuJeRQa6Qo5+iuiZQk5CafeRxLIA10/cG5YCBFNpD9RO3oqIiN4CO1Y44kxqXg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@asamuzakjp/css-color": "^7.1.3", + "@asamuzakjp/dom-selector": "^10.0.3", + "@bramus/specificity": "^2.4.2", + "@csstools/css-syntax-patches-for-csstree": "^1.1.15", + "@exodus/bytes": "^1.16.0", + "css-tree": "^3.2.1", + "data-urls": "^8.0.0", + "decimal.js": "^10.6.0", + "html-encoding-sniffer": "^7.0.0", + "is-potential-custom-element-name": "^1.0.1", + "lru-cache": "^11.5.3", + "parse5": "^8.0.1", + "saxes": "^6.0.0", + "tough-cookie": "^6.0.2", + "undici": "^8.12.1", + "w3c-xmlserializer": "^6.0.0", + "webidl-conversions": "^8.0.1", + "whatwg-mimetype": "^5.0.0", + "whatwg-url": "^17.2.0", + "xml-name-validator": "^5.0.0" + }, + "engines": { + "node": "^22.22.2 || ^24.15.0 || >=26.0.0" + }, + "peerDependencies": { + "canvas": "^3.2.3" + }, + "peerDependenciesMeta": { + "canvas": { + "optional": true + } + } + }, "node_modules/json-schema-traverse": { "version": "0.4.1", "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", @@ -2323,6 +2663,16 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/lru-cache": { + "version": "11.5.3", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-11.5.3.tgz", + "integrity": "sha512-U4N8FgzmWxc8k1VH8Kr6lQg18U7Fjvby6wXHVRX/ZZ7IwWbRMgrRbP0Wrb5q5NVinryp4SQampHKdvtecItxUg==", + "dev": true, + "license": "BlueOak-1.0.0", + "engines": { + "node": "20 || >=22" + } + }, "node_modules/magic-string": { "version": "1.4.3", "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-1.4.3.tgz", @@ -2345,6 +2695,13 @@ "source-map-js": "^1.2.1" } }, + "node_modules/mdn-data": { + "version": "2.27.1", + "resolved": "https://registry.npmjs.org/mdn-data/-/mdn-data-2.27.1.tgz", + "integrity": "sha512-9Yubnt3e8A0OKwxYSXyhLymGW4sCufcLG6VdiDdUGVkPhpqLxlvP5vl1983gQjJl3tqbrM731mjaZaP68AgosQ==", + "dev": true, + "license": "CC0-1.0" + }, "node_modules/minimatch": { "version": "11.0.4", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-11.0.4.tgz", @@ -2470,6 +2827,19 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/parse5": { + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/parse5/-/parse5-8.1.0.tgz", + "integrity": "sha512-sq3qBFpee5jeocbFbO48VHlGr8sT7mbXS0vxlKN6sottBtJzrOG3998sr0llSZcQAGgfpdmEYAIZE0P9z0dE8w==", + "dev": true, + "license": "MIT", + "dependencies": { + "entities": "^9.0.0" + }, + "funding": { + "url": "https://github.com/inikulin/parse5?sponsor=1" + } + }, "node_modules/path-exists": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", @@ -2643,6 +3013,16 @@ "dev": true, "license": "MIT" }, + "node_modules/require-from-string": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/require-from-string/-/require-from-string-2.0.2.tgz", + "integrity": "sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/requirejs": { "version": "2.3.8", "resolved": "https://registry.npmjs.org/requirejs/-/requirejs-2.3.8.tgz", @@ -2738,6 +3118,19 @@ "fsevents": "~2.3.2" } }, + "node_modules/saxes": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/saxes/-/saxes-6.0.0.tgz", + "integrity": "sha512-xAg7SOnEhrm5zI3puOOKyy1OMcMlIJZYNJY7xLBwSze0UjhPLnWfj2GF2EpT0jmzaJKIWKHLsaSSajf35bcYnA==", + "dev": true, + "license": "ISC", + "dependencies": { + "xmlchars": "^2.2.0" + }, + "engines": { + "node": ">=v12.22.7" + } + }, "node_modules/serialize-javascript": { "version": "7.1.4", "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-7.1.4.tgz", @@ -2900,6 +3293,26 @@ "node": ">=14.0.0" } }, + "node_modules/tldts": { + "version": "7.4.19", + "resolved": "https://registry.npmjs.org/tldts/-/tldts-7.4.19.tgz", + "integrity": "sha512-48dH6aSpQnpbzDUc4vIQZ1VjB8tkK+e8c1yx05/SZK+rkssgjEOlxDd/yU8/a4vGYQ9vRgJr9dwMq9TJ0b3X2Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "tldts-core": "^7.4.19" + }, + "bin": { + "tldts": "bin/cli.js" + } + }, + "node_modules/tldts-core": { + "version": "7.4.20", + "resolved": "https://registry.npmjs.org/tldts-core/-/tldts-core-7.4.20.tgz", + "integrity": "sha512-C630TWXZCZmLq0F2bW4QqwnaaxCQ/svpAqvJwnC4JvgEM5ohhBnGsEzTLSOXcN+xjz+kEaHS5uoWIw2klnqd0A==", + "dev": true, + "license": "MIT" + }, "node_modules/totalist": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/totalist/-/totalist-3.0.1.tgz", @@ -2910,6 +3323,32 @@ "node": ">=6" } }, + "node_modules/tough-cookie": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-6.0.2.tgz", + "integrity": "sha512-exgYmnmL/sJpR3upZfXG5PoatXQii55xAiXGXzY+sROLZ/Y+SLcp9PgJNI9Vz37HpQ74WvDcLT8eqm+kV3FzrA==", + "dev": true, + "license": "BSD-3-Clause", + "dependencies": { + "tldts": "^7.0.5" + }, + "engines": { + "node": ">=16" + } + }, + "node_modules/tr46": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/tr46/-/tr46-7.0.0.tgz", + "integrity": "sha512-BcDSDW+SIGWVOns1Zm6Yg91q9AEj7eaID0QDY9oIqJD1A8dscNwMcl9Sms2DeuWCNov1X0/oXanHGYQBSLwZsg==", + "dev": true, + "license": "MIT", + "dependencies": { + "punycode": "^2.3.1" + }, + "engines": { + "node": "^22.14.0 || >=24.0.0" + } + }, "node_modules/type-check": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz", @@ -2923,6 +3362,16 @@ "node": ">= 0.8.0" } }, + "node_modules/undici": { + "version": "8.12.3", + "resolved": "https://registry.npmjs.org/undici/-/undici-8.12.3.tgz", + "integrity": "sha512-+fdndUTwBP86cVjihTp21hZHo7d6oj1c/47XPA3lL8mM0XHs+C4EkcjmgRsFnFk2f/UONGDy9ItBItmXsLOQHw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=22.19.0" + } + }, "node_modules/uri-js": { "version": "4.4.1", "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", @@ -3095,6 +3544,54 @@ } } }, + "node_modules/w3c-xmlserializer": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/w3c-xmlserializer/-/w3c-xmlserializer-6.0.0.tgz", + "integrity": "sha512-4Nsy8K5Tr6SPDH9jhKJOHf7ChDrc1zufZTVSF7x72hwuEXBqxqk9G6cK+K2NRUtB3iELRJqjXb4JPDMBjMTl2Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "xml-name-validator": "^5.0.0" + }, + "engines": { + "node": "^22.22.2 || ^24.15.0 || >=26.0.0" + } + }, + "node_modules/webidl-conversions": { + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-8.0.1.tgz", + "integrity": "sha512-BMhLD/Sw+GbJC21C/UgyaZX41nPt8bUTg+jWyDeg7e7YN4xOM05YPSIXceACnXVtqyEw/LMClUQMtMZ+PGGpqQ==", + "dev": true, + "license": "BSD-2-Clause", + "engines": { + "node": ">=20" + } + }, + "node_modules/whatwg-mimetype": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/whatwg-mimetype/-/whatwg-mimetype-5.0.0.tgz", + "integrity": "sha512-sXcNcHOC51uPGF0P/D4NVtrkjSU2fNsm9iog4ZvZJsL3rjoDAzXZhkm2MWt1y+PUdggKAYVoMAIYcs78wJ51Cw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=20" + } + }, + "node_modules/whatwg-url": { + "version": "17.3.0", + "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-17.3.0.tgz", + "integrity": "sha512-KwOAJrpf+GTgBvcBQJcP38sMF0DsQKdwtG+TxM2pW44P6E5k0hDbWrDmyuJDIF0Uef0aQq0ZoJs+5oI+k8ddhg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@exodus/bytes": "^1.16.0", + "tr46": "^7.0.0", + "webidl-conversions": "^8.0.1" + }, + "engines": { + "node": "^22.14.0 || >=24.0.0" + } + }, "node_modules/which": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", @@ -3156,6 +3653,23 @@ } } }, + "node_modules/xml-name-validator": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/xml-name-validator/-/xml-name-validator-5.0.0.tgz", + "integrity": "sha512-EvGK8EJ3DhaHfbRlETOWAS5pO9MZITeauHKJyb8wyajUfQUenkIg2MvLDTZ4T/TgIcm3HU0TFBgWWboAZ30UHg==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">=18" + } + }, + "node_modules/xmlchars": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/xmlchars/-/xmlchars-2.2.0.tgz", + "integrity": "sha512-JZnDKK8B0RCDw84FNdDAIpZK+JuJw+s7Lz8nksI7SIuU3UXJJslUthsi+uWBUYOwPFwW7W7PRLRfUKpxjtjFCw==", + "dev": true, + "license": "MIT" + }, "node_modules/yocto-queue": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz", diff --git a/package.json b/package.json index a83fc723..c3117b47 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "jquery-form", - "version": "4.5.0", + "version": "4.6.0", "description": "The jQuery Form Plugin allows you to easily and unobtrusively upgrade HTML forms to use AJAX.", "keywords": [ "jquery", @@ -13,19 +13,21 @@ "jquery-form", "ecosystem:jquery" ], - "homepage": "https://github.com/jquery-form/form", + "homepage": "https://jquery-form.github.io/form/", "bugs": "https://github.com/jquery-form/form/issues", - "license": "(LGPL-2.1+ OR MIT)", + "license": "(LGPL-2.1-or-later OR MIT)", "contributors": [ "Mike Alsup", "Kevin Morris" ], "main": "dist/jquery.form.js", "module": "dist/jquery.form.mjs", - "browser": "dist/jquery.form.min.js", + "jsdelivr": "dist/jquery.form.min.js", + "unpkg": "dist/jquery.form.min.js", "files": [ "dist", - "src" + "src", + "LICENSE-MIT" ], "repository": { "type": "git", @@ -44,13 +46,18 @@ "format": "prettier --write .", "format:check": "prettier --check .", "metrics": "node scripts/code-metrics.mjs", - "test": "npm run lint && npm run format:check && npm run build && vitest run --coverage" + "test": "npm run lint && npm run format:check && npm run build && vitest run --coverage --project !suite-webkit && vitest run --project suite-webkit", + "test:docker": "scripts/test-docker.sh", + "test:e2e": "node scripts/pack-fixture.mjs && node --test test/e2e/published-node.test.mjs && playwright test", + "test:e2e:docker": "scripts/test-docker.sh --e2e", + "test:firefox": "scripts/test-docker.sh --project suite-firefox" }, "dependencies": { "jquery": ">=1.7.2" }, "devDependencies": { "@eslint/js": "10.0.1", + "@playwright/test": "1.64.1", "@rollup/plugin-terser": "1.0.2", "@vitest/browser-playwright": "5.0.5", "@vitest/coverage-v8": "5.0.5", @@ -59,6 +66,7 @@ "globals": "17.13.0", "jquery": "3.7.1", "jquery4": "npm:jquery@4.0.0", + "jsdom": "30.1.3", "magic-string": "1.4.3", "playwright": "1.64.1", "prettier": "3.9.10", diff --git a/playwright.config.mjs b/playwright.config.mjs new file mode 100644 index 00000000..53081e47 --- /dev/null +++ b/playwright.config.mjs @@ -0,0 +1,25 @@ +import { defineConfig } from "@playwright/test"; + +// End-to-end tests (npm run test:e2e): the built plugin in a real page, posting to the test server +// in test/e2e/server.mjs. JQUERY_FILE picks the jQuery build, JQUERY_FORM_DIST the plugin build. +// Firefox runs only with JQUERY_FORM_FIREFOX=1 (scripts/test-docker.sh --e2e runs it in Docker). +const port = Number(process.env.E2E_PORT || 4310); +const browsers = ["chromium", "webkit"]; +if (process.env.JQUERY_FORM_FIREFOX === "1") { + browsers.push("firefox"); +} + +export default defineConfig({ + testDir: "test/e2e", + testMatch: "*.spec.mjs", + fullyParallel: true, + forbidOnly: !!process.env.CI, + reporter: process.env.CI ? [["list"], ["github"]] : "list", + use: { baseURL: `http://127.0.0.1:${port}` }, + projects: browsers.map((name) => ({ name, use: { browserName: name } })), + webServer: { + command: "node test/e2e/server.mjs", + url: `http://127.0.0.1:${port}/page`, + reuseExistingServer: false, + }, +}); diff --git a/rollup.config.mjs b/rollup.config.mjs index 63c8e1df..23c56aab 100644 --- a/rollup.config.mjs +++ b/rollup.config.mjs @@ -6,7 +6,9 @@ import terser from "@rollup/plugin-terser"; const umdHeader = `(function (factory) { if (typeof define === 'function' && define.amd) { // AMD. Register as an anonymous module. - define(['jquery'], factory); + define(['jquery'], function (jQuery) { + factory(jQuery, window); + }); } else if (typeof module === 'object' && module.exports) { // Node/CommonJS module.exports = function( root, jQuery ) { @@ -20,17 +22,24 @@ const umdHeader = `(function (factory) { jQuery = require('jquery')(root); } } - factory(jQuery); + factory(jQuery, root || (typeof window !== 'undefined' ? window : undefined)); return jQuery; }; } else { // Browser globals - factory(jQuery); + factory(jQuery, window); } -}(function (jQuery) { +}(function (jQuery, root) { `; +// The plugin reads these as globals. In the classic build they come from the window the wrapper +// passes, so a CommonJS factory called with a root works where that root is not the global window. +const rootGlobals = + "\tvar window = root;\n" + + "\tvar document = window.document, navigator = window.navigator;\n" + + "\tvar Element = window.Element, FormData = window.FormData;\n"; + const moduleLines = /^import jQuery from ['"]jquery['"];\nexport \{ default \} from ['"]jquery['"];\n\n/; const preamble = /^\/\*![\s\S]*?\*\/\n\n?/m; @@ -68,7 +77,7 @@ const classicLayout = { const { chunk, header } = splitPreamble(this, code); // Rollup drops directives because modules are strict; a classic script is not, so the whole // factory body is made strict, including module code hoisted above the plugin body. - chunk.prepend(header + umdHeader + "\t'use strict';\n").append("\n}));\n"); + chunk.prepend(header + umdHeader + "\t'use strict';\n" + rootGlobals).append("\n}));\n"); return { code: chunk.toString(), map: chunk.generateMap({ hires: true }) }; }, }; diff --git a/scripts/pack-fixture.mjs b/scripts/pack-fixture.mjs new file mode 100644 index 00000000..a7bb30fa --- /dev/null +++ b/scripts/pack-fixture.mjs @@ -0,0 +1,47 @@ +// Packs the package as npm would publish it and installs the tarball into fixture projects, one +// per jQuery version, so the published-file tests load it by its package name. +// Usage: [JQUERY_FORM_TARBALL=path.tgz] node scripts/pack-fixture.mjs +// Without a tarball it runs `npm pack` on the current checkout (build dist first). Fixtures go to +// JQUERY_FORM_PACK_DIR (default .pack): /jquery-/node_modules/jquery-form. +import { execFileSync } from "node:child_process"; +import { mkdirSync, rmSync, writeFileSync } from "node:fs"; +import { resolve } from "node:path"; + +const root = resolve(import.meta.dirname, ".."); +const packDir = resolve(root, process.env.JQUERY_FORM_PACK_DIR || ".pack"); +const jqueryVersions = ["3.7.1", "4.0.0"]; + +function npm(args, cwd) { + return execFileSync("npm", args, { cwd, encoding: "utf8", stdio: ["ignore", "pipe", "inherit"] }); +} + +rmSync(packDir, { recursive: true, force: true }); +mkdirSync(packDir, { recursive: true }); + +let tarball = process.env.JQUERY_FORM_TARBALL && resolve(process.env.JQUERY_FORM_TARBALL); +if (!tarball) { + const [packed] = JSON.parse(npm(["pack", "--json", "--pack-destination", packDir], root)); + tarball = resolve(packDir, packed.filename); +} + +for (const version of jqueryVersions) { + const fixture = resolve(packDir, `jquery-${version}`); + mkdirSync(fixture); + writeFileSync( + resolve(fixture, "package.json"), + JSON.stringify({ name: `fixture-jquery-${version}`, private: true }, null, 2) + "\n" + ); + npm( + [ + "install", + "--prefer-offline", + "--no-audit", + "--no-fund", + "--no-package-lock", + tarball, + `jquery@${version}`, + ], + fixture + ); +} +console.log(`installed ${tarball} into ${packDir}`); diff --git a/scripts/test-docker.sh b/scripts/test-docker.sh new file mode 100755 index 00000000..e702e1cf --- /dev/null +++ b/scripts/test-docker.sh @@ -0,0 +1,41 @@ +#!/usr/bin/env bash +# Run Vitest in Playwright's Linux image (its Firefox build does not start on macOS 27). +# Usage: [JQUERY_FILE=.jquery/jquery-1.7.2.js] scripts/test-docker.sh [vitest args...] +# [JQUERY_FILE=...] scripts/test-docker.sh --e2e [playwright test args...] +# Defaults to the suite on Chromium, WebKit and Firefox; --e2e runs the end-to-end tests +# (npm run test:e2e, with the packed-package tests) instead, on all three browsers unless +# --project is given. Node and node_modules are cached in named +# volumes (jquery-form-node, jquery-form-node-modules-); the host's node_modules stays untouched. +set -euo pipefail + +playwright=$(sed -n 's/^ *"playwright": "\([0-9.]*\)".*/\1/p' package.json) +image="mcr.microsoft.com/playwright:v$playwright-noble" +node_major=$(cat .nvmrc) +lock_hash=$(shasum -a 256 package-lock.json | cut -c1-12) + +runner="npx vitest run" +if [ "${1:-}" = "--e2e" ]; then + shift + runner="npm run test:e2e --" +elif [ $# -eq 0 ]; then + set -- --project suite-chromium --project suite-webkit --project suite-firefox +fi + +exec docker run --rm --init --ipc=host \ + -v "$PWD":/work -w /work \ + -v jquery-form-node:/opt/node \ + -v "jquery-form-node-modules-$lock_hash":/work/node_modules \ + -e N_PREFIX=/opt/node -e PATH="/opt/node/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" \ + -e JQUERY_FILE="${JQUERY_FILE:-}" -e JQUERY_FORM_FIREFOX=1 -e JQUERY_FORM_TARBALL="${JQUERY_FORM_TARBALL:-}" -e RUNNER="$runner" \ + "$image" bash -euo pipefail -c ' + if ! node --version 2>/dev/null | grep -q "^v'"$node_major"'\."; then + (cd /tmp && npx --yes n '"$node_major"' >/dev/null) + hash -r + fi + if [ ! -f node_modules/.installed ]; then + npm ci --no-audit --no-fund >/dev/null + touch node_modules/.installed + fi + npx playwright install chromium webkit firefox >/dev/null + $RUNNER "$@" + ' bash "$@" diff --git a/src/form-members.js b/src/form-members.js index 835f722f..130ee107 100644 --- a/src/form-members.js +++ b/src/form-members.js @@ -55,6 +55,14 @@ export function tagName(el) { return typeof name === "string" ? name.toLowerCase() : ""; } +/** + * Whether a control or option is disabled, also through a disabled fieldset or optgroup. Without + * selector matching, only its own disabled property is read. + */ +export function isDisabled(el) { + return typeof el.matches === "function" ? el.matches(":disabled") : !!el.disabled; +} + // Elements only: the subject of formToArray may also be the document or a plain object. export function isElement(node) { return formMember(node, "nodeType") === 1; diff --git a/src/iframe-lifecycle.js b/src/iframe-lifecycle.js index 06813768..664d65be 100644 --- a/src/iframe-lifecycle.js +++ b/src/iframe-lifecycle.js @@ -164,8 +164,12 @@ export function createLifecycle(s, frame) { return; } - // an emulated HTTP error status wins, as in $.ajax; a parse error is kept otherwise + // an emulated HTTP error status wins with the statusText, as in $.ajax; a parse error is + // kept otherwise if (xhr.status && !((xhr.status >= 200 && xhr.status < 300) || xhr.status === 304)) { + if (status === "parsererror") { + errMsg = undefined; + } status = "error"; } @@ -190,7 +194,7 @@ export function createLifecycle(s, frame) { if (s.error) { s.error.call(s.context, xhr, status, errMsg); } - deferred.reject(xhr, "error", errMsg); + deferred.reject(xhr, status, errMsg); if (g) { $.event.trigger("ajaxError", [xhr, s, errMsg]); } diff --git a/src/iframe-post.js b/src/iframe-post.js index 0ccd286a..444ae54a 100644 --- a/src/iframe-post.js +++ b/src/iframe-post.js @@ -2,6 +2,7 @@ import { callFormMethod } from "./form-members.js"; import { deepSerialize } from "./xhr-transport.js"; import jQuery from "jquery"; import { submitterFields } from "./submitter.js"; +import { wellFormed } from "./successful-controls.js"; // The iframe form post: the extra fields (submitter, CSRF, data), the form attributes set while // posting and restored after, and the native submit. @@ -38,7 +39,7 @@ export function addSubmitterFields(s, form) { for (var n in fields) { s.extraData = s.extraData || {}; - s.extraData[n] = fields[n]; + s.extraData[wellFormed(n)] = wellFormed(fields[n]); } } @@ -127,7 +128,7 @@ export function addExtraInputs(form, ownerDocument, extraData, traditional, adde hasOwn.call(extraData[n], "name") && hasOwn.call(extraData[n], "value") ) { - addHiddenInput(extraData[n].name, extraData[n].value); + addHiddenInput(wellFormed(extraData[n].name), wellFormed(extraData[n].value)); } else { // arrays and objects become one field per value, as $.param sends them (#597) var single = {}; diff --git a/src/iframe-transport.js b/src/iframe-transport.js index affb9d31..11ec70bc 100644 --- a/src/iframe-transport.js +++ b/src/iframe-transport.js @@ -10,9 +10,9 @@ import { import { closestByTag, formMember } from "./form-members.js"; import { deprecate, log } from "./diagnostics.js"; import { getDoc, readResponse } from "./iframe-response.js"; +import { keepContext, selectorOption } from "./options.js"; import { createLifecycle } from "./iframe-lifecycle.js"; import jQuery from "jquery"; -import { keepContext } from "./options.js"; // The iframe transport: posts the form itself into a hidden frame and reads the response from it, // for file uploads without the File API or when the iframe option asks for it. @@ -56,7 +56,7 @@ export function createIframeTransport(hasProp, forms) { var $io, n; if (s.iframeTarget) { - $io = $(s.iframeTarget, ownerDocument); + $io = selectorOption(s.iframeTarget, ownerDocument); n = $io.attr("name"); if (!n) { $io.attr("name", id); diff --git a/src/jquery.form.js b/src/jquery.form.js index 51c777aa..b1c8b940 100644 --- a/src/jquery.form.js +++ b/src/jquery.form.js @@ -1,6 +1,6 @@ /*! * jQuery Form Plugin - * version: 4.5.0 + * version: 4.6.0 * Requires jQuery v1.7.2 or later * Project repository: https://github.com/jquery-form/form @@ -23,9 +23,9 @@ import { ajaxForm, ajaxFormUnbind } from "./ajax-form.js"; import { callFormMethod, tagName } from "./form-members.js"; import { createSuccessfulControls, - isSuccessful, - urlencodedFields, - valueOf, + deprecateFieldValueOverride, + fieldValue, + urlencode, } from "./successful-controls.js"; import { deprecate, deprecateOldJQuery, log } from "./diagnostics.js"; import { sendAjax, sendFormData } from "./xhr-transport.js"; @@ -34,7 +34,6 @@ import { createSubmission } from "./submission.js"; import { formAttribute } from "./form-attributes.js"; import jQuery from "jquery"; import { submitOptions } from "./options.js"; -import { submitterElement } from "./submitter.js"; (function ($) { "use strict"; @@ -202,7 +201,7 @@ import { submitterElement } from "./submitter.js"; */ $.fn.formSerialize = function (semantic) { // hand off to jQuery.param for proper encoding - return $.param(urlencodedFields(this.formToArray(semantic))); + return urlencode(this.formToArray(semantic)); }; /** @@ -212,6 +211,8 @@ import { submitterElement } from "./submitter.js"; $.fn.fieldSerialize = function (successful) { var a = []; + deprecateFieldValueOverride(); + this.each(function () { var n = this.name; @@ -232,7 +233,7 @@ import { submitterElement } from "./submitter.js"; }); // hand off to jQuery.param for proper encoding - return $.param(a); + return urlencode(a); }; /** @@ -295,15 +296,7 @@ import { submitterElement } from "./submitter.js"; /** * Returns the value of the field element. */ - $.fieldValue = function (el, successful) { - var required = typeof successful === "undefined" || successful; - - if (required && !isSuccessful(el, submitterElement(el.form))) { - return null; - } - - return valueOf(el); - }; + $.fieldValue = fieldValue; /** * Clears the form data. Takes the following actions on the form's input fields: diff --git a/src/options.js b/src/options.js index 4f064d41..d0ded32d 100644 --- a/src/options.js +++ b/src/options.js @@ -1,3 +1,6 @@ +import jQuery from "jquery"; +import { log } from "./diagnostics.js"; + // The arguments ajaxSubmit and ajaxForm accept in place of an options object. /** @@ -62,3 +65,22 @@ export function keepContext(settings, sources) { return settings; } + +/** + * The elements a selector option (target, iframeTarget) names. A string is only ever a selector, + * looked up in the document, so jQuery never builds elements from it; a string starting with "<" + * is HTML, not a selector, and matches nothing. Elements and jQuery objects are used as given. + */ +export function selectorOption(value, ownerDocument) { + if (typeof value !== "string") { + return jQuery(value); + } + + if (/^\s* { + if (ctx.transport.plugin !== "multipart" || ctx.transport.native !== "urlencoded") { + return pair; + } + return { + plugin: pair.plugin.map((e) => (e[1] === "file" ? [e[0], "text", e[2]] : e)), + native: pair.native, + }; + }, + }, + { + id: "EMPTY-FILE", + description: + "a FormData upload sends an empty file input as an empty text field, native as an empty file", + normalize: (pair, ctx) => { + if (ctx.transport.iframe || ctx.transport.plugin !== "multipart") { + return pair; + } + return { + plugin: pair.plugin, + native: pair.native.map((e) => (e[1] === "file" && e[2] === "" ? [e[0], "text", ""] : e)), + }; + }, + }, + { + id: "IFRAME-SUBMITTER", + description: "an iframe upload appends the submitter's fields after the form's", + normalize: (pair, ctx) => { + const sub = ctx.submitter; + // a disabled submitter is sent by neither, so any field of it fails the comparison + if (!ctx.transport.iframe || !sub || !sub.name || isDisabled(sub)) { + return pair; + } + // The extra inputs go at the end of the form, before outside controls that follow it. + const names = submitterNames(sub); + let plugin = pair.plugin; + names.forEach(function (n) { + const index = plugin.map((e) => e[0] === n).lastIndexOf(true); + plugin = plugin.filter((e, i) => i !== index); + }); + const own = isImage(sub) + ? (e) => e[0] === names[1] || e[0] === names[2] + : (e) => e[0] === sub.name; + const index = isImage(sub) ? -1 : pair.native.map((e) => own(e)).lastIndexOf(true); + const native = isImage(sub) + ? pair.native.filter((e) => !own(e)) + : pair.native.filter((e, i) => i !== index); + return { plugin: plugin, native: native }; + }, + }, +]; + +E2E_DIFFERENCES.push({ + id: "IFRAME-DIRNAME", + description: "an iframe upload posts the form itself, so it sends dirname fields as native does", + normalize: (pair, ctx) => + ctx.transport.iframe + ? { plugin: pair.plugin.filter((e) => !/^dir-\d+$/.test(e[0])), native: pair.native } + : pair, +}); + +window.e2e = { + // A seeded form from the serialization oracle. + generate(seed, attributes) { + current = generateForm(seed, fixture()); + setAttributes(current.form, attributes); + return { + html: document.getElementById("fixture").innerHTML, + hasFiles: !!document.querySelector("#fixture input[type=file]"), + submitter: current.submitter ? current.submitter.outerHTML : null, + }; + }, + + // A hand-written form: `html` holds one form, `submitter` selects its submitter. + build(html, attributes, submitter) { + const container = fixture(); + container.innerHTML = html; + const form = container.querySelector("form"); + setAttributes(form, attributes); + current = { + form: form, + submitter: submitter ? container.querySelector(submitter) : null, + outsideNames: [], + }; + }, + + // Adds files to a file input: [{ name, type, bytes }] with bytes as numbers. + setFiles(selector, files) { + const transfer = new DataTransfer(); + files.forEach(function (file) { + transfer.items.add(new File([new Uint8Array(file.bytes)], file.name, { type: file.type })); + }); + document.querySelector(selector).files = transfer.files; + }, + + // Submits the form natively into the named frame, with its submitter when it has one. + nativeSubmit() { + const form = current.form; + const target = form.getAttribute("target"); + form.noValidate = true; + form.setAttribute("target", "native-sink"); + if (current.submitter) { + form.requestSubmit(current.submitter); + } else { + form.submit(); + } + if (target === null) { + form.removeAttribute("target"); + } else { + form.setAttribute("target", target); + } + }, + + // Submits the form with ajaxSubmit; resolves with the callbacks that ran and their arguments. + pluginSubmit(options) { + const form = current.form; + const submitter = current.submitter; + form.clk = submitter || undefined; + form.clk_x = isImage(submitter) ? 0 : undefined; + form.clk_y = isImage(submitter) ? 0 : undefined; + return new Promise(function (resolve) { + const result = { calls: [] }; + $(form).ajaxSubmit( + $.extend({}, options, { + success: function (data, status) { + result.calls.push("success"); + result.data = describeData(data); + result.status = status; + }, + error: function (xhr, status, error) { + result.calls.push("error"); + result.error = String(error); + result.status = status; + result.httpStatus = xhr.status; + result.responseText = xhr.responseText; + }, + complete: function () { + result.calls.push("complete"); + setTimeout(function () { + resolve(result); + }); + }, + }) + ); + }); + }, + + // Applies the known differences to [name, kind, value] lists of the current form: the + // end-to-end classes first, then the serialization oracle's. + normalize(plugin, native, transport) { + const ctx = { + submitter: current.submitter, + outsideNames: current.outsideNames, + semantic: false, + transport: transport, + }; + let pair = { plugin: plugin, native: native }; + E2E_DIFFERENCES.forEach(function (known) { + pair = known.normalize(pair, ctx); + }); + return applyKnownDifferences(pair.plugin, pair.native, ctx); + }, +}; diff --git a/test/e2e/helpers.mjs b/test/e2e/helpers.mjs new file mode 100644 index 00000000..34ea4668 --- /dev/null +++ b/test/e2e/helpers.mjs @@ -0,0 +1,82 @@ +import { expect } from "@playwright/test"; + +let counter = 0; + +// A fresh request id per submission pair, so parallel tests never read each other's requests. +export function requestId(testInfo) { + counter += 1; + return `${testInfo.workerIndex}-${testInfo.testId}-${counter}`; +} + +// Waits until the server recorded `count` requests for `id`, and returns them. +export async function requests(request, id, count) { + let list = []; + await expect + .poll( + async () => { + list = await (await request.get(`/requests?id=${encodeURIComponent(id)}`)).json(); + return list.length; + }, + { timeout: 10000 } + ) + .toBeGreaterThanOrEqual(count); + return list; +} + +// [name, kind, value] triples, as the shared known differences expect them (files by name). +export function entries(fields) { + return (fields || []).map((f) => [f.name, f.kind, f.value]); +} + +// Files with their type and bytes. +export function files(fields) { + return (fields || []).filter((f) => f.kind === "file").map((f) => [f.name, f.value, f.base64]); +} + +// "multipart", "urlencoded", or "none" for a request without a form body. +export function encoding(recorded) { + const type = recorded.headers["content-type"] || ""; + if (/^multipart\/form-data/i.test(type)) { + return "multipart"; + } + return /^application\/x-www-form-urlencoded/i.test(type) ? "urlencoded" : "none"; +} + +// The fields a request carries: the parsed body, or the query string for GET. +export function sent(recorded) { + return recorded.method === "GET" ? recorded.query : recorded.fields; +} + +// Submits the current form natively, then through the plugin; returns both recorded requests and +// the plugin's callbacks. +export async function submitBoth(page, request, id, options) { + await page.evaluate(() => window.e2e.nativeSubmit()); + await requests(request, id, 1); + const result = await page.evaluate((o) => window.e2e.pluginSubmit(o), options || {}); + // An upload that throws before it posts sends nothing. + if (/Error/.test(result.error || "")) { + return { native: (await requests(request, id, 1))[0], plugin: null, result }; + } + const [native, plugin] = await requests(request, id, 2); + return { native, plugin, result }; +} + +// Compares the plugin's request with the native one after the shared known differences. +export async function expectSameFields(page, native, plugin, context) { + const transport = { + plugin: encoding(plugin), + native: encoding(native), + iframe: !plugin.headers["x-requested-with"], + }; + const pair = await page.evaluate( + ([p, n, t]) => window.e2e.normalize(p, n, t), + [entries(sent(plugin)), entries(sent(native)), transport] + ); + const normalized = `normalized plugin: ${JSON.stringify(pair.plugin)}\nnormalized native: ${JSON.stringify(pair.native)}`; + expect(pair.plugin, `unlisted difference\n${context}\n${normalized}`).toEqual(pair.native); +} + +export async function openPage(page) { + await page.goto("/page"); + await page.waitForFunction(() => window.e2e && window.jQuery && window.jQuery.fn.ajaxSubmit); +} diff --git a/test/e2e/published-node.test.mjs b/test/e2e/published-node.test.mjs new file mode 100644 index 00000000..4ca79e4f --- /dev/null +++ b/test/e2e/published-node.test.mjs @@ -0,0 +1,258 @@ +// Node side of the published-file tests (node --test): the packed tarball, installed into the +// fixture projects by scripts/pack-fixture.mjs, loaded by package name from CommonJS and from an +// ES module, with jsdom as the window. Each case runs in its own process, so globals and module +// caches never leak between cases. +import { after, before, describe, it } from "node:test"; +import { existsSync, readFileSync } from "node:fs"; +import assert from "node:assert/strict"; +import { createRequire } from "node:module"; +import { createServer } from "node:http"; +import { execFile } from "node:child_process"; +import { promisify } from "node:util"; +import { resolve } from "node:path"; + +const require = createRequire(import.meta.url); +const root = resolve(import.meta.dirname, "../.."); +const packDir = resolve(root, process.env.JQUERY_FORM_PACK_DIR || ".pack"); +const jqueryFile = resolve(root, process.env.JQUERY_FILE || "node_modules/jquery/dist/jquery.js"); +const jqueryVersion = readFileSync(jqueryFile, "utf8").match( + /jQuery JavaScript Library v([\w.-]+)/ +)[1]; +const FIXTURE_VERSIONS = ["3.7.1", "4.0.0"]; + +let server; +let origin; + +// Answers every request with the urlencoded body it received, as JSON. +before(async () => { + server = createServer((req, res) => { + const chunks = []; + req.on("data", (chunk) => chunks.push(chunk)); + req.on("end", () => { + res.writeHead(200, { "Content-Type": "application/json" }); + res.end(JSON.stringify({ method: req.method, body: Buffer.concat(chunks).toString() })); + }); + }); + await new Promise((done) => server.listen(0, "127.0.0.1", done)); + origin = `http://127.0.0.1:${server.address().port}`; +}); + +after(() => server.close()); + +// Code shared by every case: a jsdom window on the test server's origin, and the smoke checks. +const PRELUDE = ` +const { JSDOM } = require(process.env.JSDOM_PATH); +const dom = new JSDOM('
' + + '
', + { url: process.env.ORIGIN + "/", runScripts: "outside-only" }); +// jsdom keeps the process alive, so a case exits once it reports its result. +function report(result) { + console.log(JSON.stringify(result)); + process.exit(0); +} +function smoke($, value) { + const form = dom.window.document.querySelector("form"); + return new Promise((done) => { + $(form).ajaxSubmit({ + dataType: "json", + success: (data) => done({ data }), + error: (xhr, status, error) => done({ error: String(error || status) }), + }); + }).then((result) => ({ + jquery: $.fn.jquery, + ownWindow: $(form)[0].ownerDocument === dom.window.document, + api: ["ajaxSubmit", "ajaxForm", "formSerialize", "fieldValue", "resetForm"].every( + (name) => typeof $.fn[name] === "function"), + value: value === $ ? "jQuery" : typeof value, + serialized: $(form).formSerialize(), + ...result, + })); +} +`; + +// Runs a case in a fresh Node process in `cwd`; resolves the JSON it prints last. Asynchronous, +// so this process keeps answering the case's requests. +async function run(cwd, code, type = "commonjs") { + const source = + type === "module" + ? `import { createRequire } from "node:module"; + const require = createRequire(process.cwd() + "/"); + ${PRELUDE} + ${code}` + : `${PRELUDE}\n(async () => { ${code} })();`; + const { stdout } = await promisify(execFile)( + process.execPath, + [`--input-type=${type}`, "-e", source], + { + cwd, + encoding: "utf8", + timeout: 20000, + env: { ...process.env, JSDOM_PATH: require.resolve("jsdom"), ORIGIN: origin }, + } + ); + return JSON.parse(stdout.trim().split("\n").pop()); +} + +function expected(version, value) { + return { + jquery: version, + ownWindow: true, + api: true, + value, + serialized: "text=plain+%C3%BC&pick=b", + data: { method: "POST", body: "text=plain+%C3%BC&pick=b" }, + }; +} + +describe("when the packed package is installed", () => { + const installed = resolve(packDir, "jquery-3.7.1/node_modules/jquery-form"); + + it("should ship every file its package.json points at", () => { + // Arrange + const manifest = JSON.parse(readFileSync(resolve(installed, "package.json"), "utf8")); + + // Act + const entries = [manifest.main, manifest.module, manifest.jsdelivr, manifest.unpkg]; + + // Assert + assert.deepEqual( + entries.filter((entry) => !existsSync(resolve(installed, entry))), + [] + ); + }); + + it("should ship both license files of the dual license", () => { + // Arrange + const files = ["LICENSE", "LICENSE-MIT"]; + + // Act + const missing = files.filter((file) => !existsSync(resolve(installed, file))); + + // Assert + assert.deepEqual(missing, []); + }); +}); + +// Makes the jsdom window global, as a test environment such as jest-environment-jsdom does. +const GLOBALS = `globalThis.window = dom.window; globalThis.document = dom.window.document;`; +// Runs the jQuery build under test inside the jsdom window. +const EVAL_JQUERY = `dom.window.eval(require("node:fs").readFileSync(${JSON.stringify(jqueryFile)}, "utf8"));`; +// Reports what a case threw instead of its smoke result. +const settle = (code) => `try { ${code} } catch (error) { report({ thrown: error.message }); }`; + +describe("when the packed package is required from CommonJS", () => { + const fixture = resolve(packDir, "jquery-3.7.1"); + + it("should export a (root, jQuery) factory without touching a DOM", async () => { + // Arrange + const code = `const factory = require("jquery-form");`; + + // Act + const result = await run( + fixture, + `${code} report({ type: typeof factory, length: factory.length });` + ); + + // Assert + assert.deepEqual(result, { type: "function", length: 2 }); + }); + + it(`should install on the jQuery ${jqueryVersion} it is given when a window is global`, async () => { + // Arrange + const code = `${GLOBALS} ${EVAL_JQUERY} + const $ = dom.window.jQuery; + const value = require("jquery-form")(dom.window, $);`; + + // Act + const result = await run(fixture, `${code} report(await smoke($, value));`); + + // Assert + assert.deepEqual(result, expected(jqueryVersion, "jQuery")); + }); + + it(`should work on the jQuery ${jqueryVersion} and window it is given when no window is global`, async () => { + // Arrange + const code = `${EVAL_JQUERY} + const $ = dom.window.jQuery; + const value = require("jquery-form")(dom.window, $);`; + + // Act + const result = await run(fixture, settle(`${code} report(await smoke($, value));`)); + + // Assert + assert.deepEqual(result, expected(jqueryVersion, "jQuery")); + }); + + for (const version of FIXTURE_VERSIONS) { + it(`should use the installed jQuery ${version} when a window is global`, async () => { + // Arrange + const code = `${GLOBALS} const $ = require("jquery-form")(dom.window);`; + + // Act + const result = await run( + resolve(packDir, `jquery-${version}`), + `${code} report(await smoke($, $));` + ); + + // Assert + assert.deepEqual(result, expected(version, "jQuery")); + }); + + it(`should build the installed jQuery ${version} on a window that is not global, where jQuery allows it`, async () => { + // Arrange + const code = `const $ = require("jquery-form")(dom.window);`; + + // Act + const result = await run( + resolve(packDir, `jquery-${version}`), + settle(`${code} report(await smoke($, $));`) + ); + + // Assert: jQuery 4 throws when required without a global window instead of returning a + // factory, so require('jquery')(root) never runs (a jQuery limit, not the plugin's). + if (version === "3.7.1") { + assert.deepEqual(result, expected(version, "jQuery")); + } else { + assert.match(result.thrown, /^jQuery requires a window with a document$/); + } + }); + } +}); + +describe("when the packed package is imported as an ES module", () => { + for (const version of FIXTURE_VERSIONS) { + it(`should resolve its name to the CommonJS factory (jQuery ${version})`, async () => { + // Arrange: Node ignores the "module" field, and the package has no "exports" map. + const code = `${GLOBALS} + const { default: factory } = await import("jquery-form"); + const { default: $ } = await import("jquery");`; + + // Act + const result = await run( + resolve(packDir, `jquery-${version}`), + `${code} const value = factory(dom.window); report(await smoke($, value));`, + "module" + ); + + // Assert + assert.deepEqual(result, expected(version, "jQuery")); + }); + + it(`should install the module build on the installed jQuery ${version} and export it`, async () => { + // Arrange: the module build reads the DOM at import time, so the window must be global. + const code = `${GLOBALS} + const { default: value } = await import("jquery-form/dist/jquery.form.mjs"); + const { default: $ } = await import("jquery");`; + + // Act + const result = await run( + resolve(packDir, `jquery-${version}`), + `${code} report(await smoke($, value));`, + "module" + ); + + // Assert + assert.deepEqual(result, expected(version, "jQuery")); + }); + } +}); diff --git a/test/e2e/published.js b/test/e2e/published.js new file mode 100644 index 00000000..3b0284af --- /dev/null +++ b/test/e2e/published.js @@ -0,0 +1,102 @@ +// In-page side of the published-file tests: each page loads jQuery and the packed plugin through +// one loader, then calls published.ready with the jQuery that loader handed back and the value +// the plugin's module resolved to. The smoke checks run on that jQuery. Exposed as window.published. +(function () { + var state = null; + + // Settles with the callbacks that ran and the data the server answered. + function settle(run) { + return new Promise(function (resolve) { + var result = { calls: [] }; + run({ + success: function (data) { + result.calls.push("success"); + result.data = data; + }, + error: function (xhr, status, error) { + result.calls.push("error"); + result.error = String(error || status); + }, + complete: function () { + result.calls.push("complete"); + setTimeout(function () { + resolve(result); + }); + }, + }); + }); + } + + function fixture(html) { + var container = document.getElementById("fixture"); + container.innerHTML = html; + return container.querySelector("form"); + } + + window.published = { + ready: function (loader, $, value) { + state = { loader: loader, $: $, value: value }; + }, + + // Which jQuery the plugin landed on, and what the loader resolved the plugin to. + describe: function () { + var $ = state.$; + var names = [ + "ajaxSubmit", + "ajaxForm", + "ajaxFormUnbind", + "attr2", + "formToArray", + "formSerialize", + "fieldSerialize", + "fieldValue", + "clearForm", + "clearFields", + "clearInputs", + "resetForm", + "enable", + "selected", + ]; + return { + loader: state.loader, + jquery: $.fn.jquery, + missing: names.filter(function (name) { + return typeof $.fn[name] !== "function"; + }), + staticFieldValue: typeof $.fieldValue, + debug: $.fn.ajaxSubmit.debug, + value: state.value === $ ? "jQuery" : typeof state.value, + global: window.jQuery === undefined ? "none" : window.jQuery === $ ? "same" : "other", + }; + }, + + // ajaxSubmit over XHR, posting a form urlencoded. + xhr: function (action) { + var form = fixture( + '
' + + '
' + ); + form.setAttribute("action", action); + return settle(function (callbacks) { + state.$(form).ajaxSubmit(state.$.extend({ dataType: "json" }, callbacks)); + }); + }, + + // ajaxForm with a file, through the iframe transport, submitted by a button click. + upload: function (action) { + var form = fixture( + '
' + + '' + + '
' + ); + form.setAttribute("action", action); + var transfer = new DataTransfer(); + transfer.items.add(new File(["file bytes"], "a.txt", { type: "text/plain" })); + form.querySelector("input[type=file]").files = transfer.files; + return settle(function (callbacks) { + state.$(form).ajaxForm(state.$.extend({ iframe: true, dataType: "json" }, callbacks)); + form.querySelector("button").click(); + }); + }, + }; +})(); diff --git a/test/e2e/published.spec.mjs b/test/e2e/published.spec.mjs new file mode 100644 index 00000000..46bdc6dd --- /dev/null +++ b/test/e2e/published.spec.mjs @@ -0,0 +1,111 @@ +import { readFileSync } from "node:fs"; +import { resolve } from "node:path"; +import { expect, test } from "@playwright/test"; +import { requestId, requests } from "./helpers.mjs"; + +// The packed tarball (scripts/pack-fixture.mjs), loaded by the entry points its package.json +// names, through each loader. Every loader runs the same smoke checks, so the minified build +// must give the same results as the plain one. +const jqueryFile = resolve( + import.meta.dirname, + "../..", + process.env.JQUERY_FILE || "node_modules/jquery/dist/jquery.js" +); +const jqueryVersion = readFileSync(jqueryFile, "utf8").match( + /jQuery JavaScript Library v([\w.-]+)/ +)[1]; +const hasModuleBuild = /^[4-9]\./.test(jqueryVersion); + +const LOADERS = [ + { name: "a script tag", path: "/published/script", value: "jQuery", global: "same" }, + { + name: "a script tag, minified", + path: "/published/script?min", + value: "jQuery", + global: "same", + }, + { name: "RequireJS", path: "/published/amd", value: "undefined", global: "same" }, + { name: "RequireJS, minified", path: "/published/amd?min", value: "undefined", global: "same" }, + { + name: "an import map", + path: "/published/esm", + value: "jQuery", + // jQuery 4's module build sets no global; older versions load as a script and export it. + global: hasModuleBuild ? "none" : "same", + }, +]; + +for (const loader of LOADERS) { + test.describe(`when the packed plugin is loaded by ${loader.name}`, () => { + test.beforeEach(async ({ page }) => { + await page.goto(loader.path); + await page.waitForFunction(() => window.published && window.published.describe); + await page.waitForFunction(() => { + try { + return !!window.published.describe(); + } catch { + return false; + } + }); + }); + + test("should install the public API on the jQuery the loader returns", async ({ page }) => { + // Arrange: the page loaded the plugin. + + // Act + const described = await page.evaluate(() => window.published.describe()); + + // Assert + expect(described).toEqual({ + loader: loader.path.slice(11).replace("?min", ""), + jquery: jqueryVersion, + missing: [], + staticFieldValue: "function", + debug: false, + value: loader.value, + global: loader.global, + }); + }); + + test("should post a form over XHR with ajaxSubmit", async ({ page, request }, testInfo) => { + // Arrange + const id = requestId(testInfo); + + // Act + const result = await page.evaluate((url) => window.published.xhr(url), `/r/${id}/json`); + + // Assert + expect(result.calls, result.error).toEqual(["success", "complete"]); + expect(result.data).toEqual({ ok: true, text: "ü" }); + const [sent] = await requests(request, id, 1); + expect(sent.headers["x-requested-with"]).toBe("XMLHttpRequest"); + expect(sent.fields).toEqual([ + { name: "text", kind: "text", value: "plain ü" }, + { name: "pick", kind: "text", value: "b" }, + ]); + }); + + test("should upload a file through the iframe with ajaxForm", async ({ + page, + request, + }, testInfo) => { + // Arrange + const id = requestId(testInfo); + + // Act + const result = await page.evaluate((url) => window.published.upload(url), `/r/${id}/json`); + + // Assert + expect(result.calls, result.error).toEqual(["success", "complete"]); + expect(result.data).toEqual({ ok: true, text: "ü" }); + const [sent] = await requests(request, id, 1); + expect(sent.headers["x-requested-with"]).toBeUndefined(); + expect(sent.fields.map((f) => [f.name, f.kind, f.value])).toEqual([ + ["text", "text", "plain"], + ["upload", "file", "a.txt"], + ["go", "text", "clicked"], + ]); + expect(Buffer.from(sent.fields[1].base64, "base64").toString()).toBe("file bytes"); + }); + }); +} diff --git a/test/e2e/requests.spec.mjs b/test/e2e/requests.spec.mjs new file mode 100644 index 00000000..5926e7f7 --- /dev/null +++ b/test/e2e/requests.spec.mjs @@ -0,0 +1,281 @@ +import { expect, test } from "@playwright/test"; +import { + encoding, + entries, + expectSameFields, + files, + openPage, + requestId, + requests, + sent, +} from "./helpers.mjs"; + +// Hand-written forms through each transport: the plugin's request must equal a native submit of +// the same form after parsing, modulo the known differences; extra data has no native counterpart. +const FORM = `
+ + + + + + + + + +
`; + +const BYTES = Array.from({ length: 256 }, (v, i) => i); + +const TRANSPORTS = [ + { name: "a urlencoded XHR post", enctype: null, file: false, options: {} }, + { name: "a multipart XHR post", enctype: "multipart/form-data", file: true, options: {} }, + { + name: "an iframe upload", + enctype: "multipart/form-data", + file: true, + options: { iframe: true }, + }, +]; + +async function arrange(page, id, attributes, options) { + const settings = Object.assign({ file: false, submitter: "button[name=go]" }, options); + await page.evaluate( + ([html, attrs, submitter, withFile]) => { + window.e2e.build(html, attrs, submitter); + document.querySelector("#fixture textarea").value = "one\r\ntwo\nthree\rfour"; + if (!withFile) { + document.querySelector("#fixture input[type=file]").remove(); + } + }, + [ + FORM, + Object.assign({ action: `/r/${id}/ok`, method: "post" }, attributes), + settings.submitter, + settings.file, + ] + ); + if (settings.file) { + await page.evaluate( + (bytes) => + window.e2e.setFiles("#fixture input[type=file]", [ + { name: "bytes ü.bin", type: "application/octet-stream", bytes: bytes }, + ]), + BYTES + ); + } +} + +async function nativeSubmit(page, request, id) { + await page.evaluate(() => window.e2e.nativeSubmit()); + return (await requests(request, id, 1))[0]; +} + +async function pluginSubmit(page, request, id, options, count) { + const result = await page.evaluate((o) => window.e2e.pluginSubmit(o), options); + expect(result.calls, result.error).toEqual(["success", "complete"]); + return (await requests(request, id, count || 2))[(count || 2) - 1]; +} + +test.describe("requests the plugin sends", () => { + test.beforeEach(async ({ page }) => { + await openPage(page); + }); + + for (const transport of TRANSPORTS) { + test.describe(`when a form is sent as ${transport.name}`, () => { + test("it should send the fields, unicode, line breaks and submitter as a native submit does", async ({ + page, + request, + }, testInfo) => { + const id = requestId(testInfo); + await arrange(page, id, { enctype: transport.enctype }, { file: transport.file }); + + const native = await nativeSubmit(page, request, id); + const plugin = await pluginSubmit(page, request, id, transport.options); + + expect(plugin.method).toBe("POST"); + expect(encoding(plugin)).toBe(transport.file ? "multipart" : "urlencoded"); + await expectSameFields(page, native, plugin, transport.name); + }); + + test("it should send the form without a submitter as a native submit does", async ({ + page, + request, + }, testInfo) => { + const id = requestId(testInfo); + await arrange( + page, + id, + { enctype: transport.enctype }, + { file: transport.file, submitter: null } + ); + + const native = await nativeSubmit(page, request, id); + const plugin = await pluginSubmit(page, request, id, transport.options); + + expect(entries(sent(plugin)).map((e) => e[0])).not.toContain("go"); + await expectSameFields(page, native, plugin, transport.name); + }); + + test("it should send extraData after the form's fields", async ({ + page, + request, + }, testInfo) => { + const id = requestId(testInfo); + await arrange(page, id, { enctype: transport.enctype }, { file: transport.file }); + const options = Object.assign({}, transport.options, { + data: { extra: "x ü\r\ny", list: ["1", "2"] }, + }); + + const native = await nativeSubmit(page, request, id); + const plugin = await pluginSubmit(page, request, id, options); + + const pluginEntries = entries(sent(plugin)); + const nativeCount = entries(sent(native)).length; + expect(pluginEntries.length).toBe(nativeCount + 3); + const extra = transport.options.iframe + ? pluginEntries.filter((e) => e[0] === "extra" || e[0] === "list[]") + : pluginEntries.slice(nativeCount); + expect(extra).toEqual([ + ["extra", "text", "x ü\r\ny"], + ["list[]", "text", "1"], + ["list[]", "text", "2"], + ]); + }); + }); + } + + test.describe("when a file is uploaded", () => { + for (const transport of TRANSPORTS.filter((t) => t.file)) { + test(`as ${transport.name}, it should send the file's name, type and bytes as a native submit does`, async ({ + page, + request, + }, testInfo) => { + const id = requestId(testInfo); + await arrange(page, id, { enctype: transport.enctype }, { file: true }); + + const native = await nativeSubmit(page, request, id); + const plugin = await pluginSubmit(page, request, id, transport.options); + + expect(files(plugin.fields)).toEqual(files(native.fields)); + expect(plugin.fields.filter((f) => f.kind === "file")[0].type).toBe( + "application/octet-stream" + ); + expect(Buffer.from(files(plugin.fields)[0][2], "base64")).toEqual(Buffer.from(BYTES)); + }); + } + }); + + test.describe("when a form is sent urlencoded", () => { + test("it should send the native body byte for byte", async ({ page, request }, testInfo) => { + const id = requestId(testInfo); + await arrange(page, id, {}); + + const native = await nativeSubmit(page, request, id); + const plugin = await pluginSubmit(page, request, id, {}); + + expect(Buffer.from(plugin.base64, "base64").toString("latin1")).toBe( + Buffer.from(native.base64, "base64").toString("latin1") + ); + expect(plugin.headers["content-type"]).toBe( + "application/x-www-form-urlencoded; charset=UTF-8" + ); + }); + + test("it should append string data as given", async ({ page, request }, testInfo) => { + const id = requestId(testInfo); + await arrange(page, id, {}, { submitter: null }); + + const native = await nativeSubmit(page, request, id); + const plugin = await pluginSubmit(page, request, id, { data: "a=1&b=%C3%BC" }); + + const body = Buffer.from(plugin.base64, "base64").toString("latin1"); + expect(body).toBe(Buffer.from(native.base64, "base64").toString("latin1") + "&a=1&b=%C3%BC"); + }); + }); + + test.describe("when the method is GET", () => { + for (const transport of [TRANSPORTS[0], TRANSPORTS[2]]) { + test(`as ${transport.name}, it should send the fields in the query string as a native submit does`, async ({ + page, + request, + }, testInfo) => { + const id = requestId(testInfo); + await arrange(page, id, { method: "get", enctype: transport.enctype }); + + const native = await nativeSubmit(page, request, id); + const plugin = await pluginSubmit(page, request, id, transport.options); + + expect(native.method).toBe("GET"); + expect(plugin.method).toBe("GET"); + expect(plugin.base64).toBe(""); + await expectSameFields(page, native, plugin, transport.name); + }); + } + + test("with an action that has a query, it should keep the action's query, unlike a native submit", async ({ + page, + request, + }, testInfo) => { + const id = requestId(testInfo); + await arrange(page, id, { method: "get", action: `/r/${id}/ok?keep=1` }, { submitter: null }); + + const native = await nativeSubmit(page, request, id); + const plugin = await pluginSubmit(page, request, id, {}); + + expect(native.query.map((f) => f.name)).not.toContain("keep"); + expect(plugin.query[0]).toEqual({ name: "keep", kind: "text", value: "1" }); + expect(plugin.query.slice(1)).toEqual(native.query); + }); + }); + + test.describe("when options override the form's method and action", () => { + for (const transport of TRANSPORTS) { + test(`as ${transport.name}, the method option should win over the form's method`, async ({ + page, + request, + }, testInfo) => { + const id = requestId(testInfo); + await arrange(page, id, { enctype: transport.enctype }, { file: transport.file }); + const native = await nativeSubmit(page, request, id); + await page.evaluate(() => + document.querySelector("#fixture form").setAttribute("method", "get") + ); + + const plugin = await pluginSubmit( + page, + request, + id, + Object.assign({ method: "POST" }, transport.options) + ); + + expect(plugin.method).toBe("POST"); + await expectSameFields(page, native, plugin, transport.name); + }); + + test(`as ${transport.name}, the url option should win over the form's action`, async ({ + page, + request, + }, testInfo) => { + const id = requestId(testInfo); + await arrange(page, id, { enctype: transport.enctype }, { file: transport.file }); + const native = await nativeSubmit(page, request, id); + await page.evaluate( + (i) => + document.querySelector("#fixture form").setAttribute("action", `/r/${i}-unused/ok`), + id + ); + + const plugin = await pluginSubmit( + page, + request, + id, + Object.assign({ url: `/r/${id}/ok` }, transport.options) + ); + + expect(plugin.url.split("?")[0]).toBe(native.url); + await expectSameFields(page, native, plugin, transport.name); + }); + } + }); +}); diff --git a/test/e2e/responses.spec.mjs b/test/e2e/responses.spec.mjs new file mode 100644 index 00000000..4a98c284 --- /dev/null +++ b/test/e2e/responses.spec.mjs @@ -0,0 +1,132 @@ +import { expect, test } from "@playwright/test"; +import { openPage, requestId, requests } from "./helpers.mjs"; + +// Server responses through the plugin's callbacks. No native counterpart: hand-written expectations. +const FORM = `
`; + +const TRANSPORTS = [ + { name: "an XHR post", options: {}, iframe: false }, + { name: "an iframe upload", options: { iframe: true }, iframe: true }, +]; + +async function submit(page, request, testInfo, response, options) { + const id = requestId(testInfo); + await page.evaluate( + ([html, action]) => window.e2e.build(html, { action: action }, null), + [FORM, `/r/${id}/${response}`] + ); + const result = await page.evaluate((o) => window.e2e.pluginSubmit(o), options); + await requests(request, id, 1); + return result; +} + +test.describe("responses the plugin delivers", () => { + test.beforeEach(async ({ page }) => { + await openPage(page); + }); + + for (const transport of TRANSPORTS) { + test.describe(`when ${transport.name} gets a response`, () => { + test("with JSON and dataType json, it should pass the parsed object to success", async ({ + page, + request, + }, testInfo) => { + const options = Object.assign({ dataType: "json" }, transport.options); + + const result = await submit(page, request, testInfo, "json", options); + + expect(result.calls).toEqual(["success", "complete"]); + expect(result.data).toEqual({ ok: true, text: "ü" }); + }); + + test("with XML and dataType xml, it should pass the XML document to success", async ({ + page, + request, + }, testInfo) => { + const options = Object.assign({ dataType: "xml" }, transport.options); + + const result = await submit(page, request, testInfo, "xml", options); + + expect(result.calls).toEqual(["success", "complete"]); + expect(result.data).toEqual({ xml: "root", text: "ü" }); + }); + + test("with HTML, it should pass the markup to success", async ({ + page, + request, + }, testInfo) => { + const options = Object.assign({ dataType: "html" }, transport.options); + + const result = await submit(page, request, testInfo, "html", options); + + expect(result.calls).toEqual(["success", "complete"]); + expect(result.data).toBe('

ü

'); + }); + + test("with plain text, it should pass the text to success", async ({ + page, + request, + }, testInfo) => { + const options = Object.assign({ dataType: "text" }, transport.options); + + const result = await submit(page, request, testInfo, "text", options); + + expect(result.calls).toEqual(["success", "complete"]); + expect(result.data).toBe("plain ü"); + }); + + test("with a script and dataType script, it should run the script once", async ({ + page, + request, + }, testInfo) => { + const options = Object.assign({ dataType: "script" }, transport.options); + + const result = await submit(page, request, testInfo, "script", options); + + expect(result.calls).toEqual(["success", "complete"]); + expect(await page.evaluate(() => window.e2eScriptRuns)).toBe(1); + }); + }); + } + + test.describe("when an XHR post gets an error status", () => { + for (const status of [404, 500]) { + test(`with ${status}, it should call error with the status and the response text`, async ({ + page, + request, + }, testInfo) => { + const result = await submit(page, request, testInfo, `status-${status}`, {}); + + expect(result.calls).toEqual(["error", "complete"]); + expect(result.status).toBe("error"); + expect(result.httpStatus).toBe(status); + expect(result.responseText).toBe(status === 404 ? "missing" : "broken"); + }); + } + }); + + test.describe("when an iframe upload gets an error status", () => { + test("it should call success with the error page, since a frame cannot see the status", async ({ + page, + request, + }, testInfo) => { + const options = { iframe: true, dataType: "text" }; + + const result = await submit(page, request, testInfo, "status-500", options); + + expect(result.calls).toEqual(["success", "complete"]); + expect(result.data).toBe("broken"); + }); + }); + + test.describe("when an iframe upload gets JSON wrapped in a textarea", () => { + test("it should pass the parsed object to success", async ({ page, request }, testInfo) => { + const options = { iframe: true, dataType: "json" }; + + const result = await submit(page, request, testInfo, "textarea-json", options); + + expect(result.calls).toEqual(["success", "complete"]); + expect(result.data).toEqual({ ok: true, text: "ü" }); + }); + }); +}); diff --git a/test/e2e/seeded-forms.spec.mjs b/test/e2e/seeded-forms.spec.mjs new file mode 100644 index 00000000..1955bc7a --- /dev/null +++ b/test/e2e/seeded-forms.spec.mjs @@ -0,0 +1,66 @@ +import { expect, test } from "@playwright/test"; +import { SEEDS } from "../shared/oracle-forms.js"; +import { + encoding, + entries, + expectSameFields, + openPage, + requestId, + sent, + submitBoth, +} from "./helpers.mjs"; + +// The serialization oracle's seeded forms, posted natively and through the plugin to the server. +// The plugin's request must carry what the native one does, modulo the known differences. +const MODES = [ + { name: "a urlencoded XHR post", enctype: "application/x-www-form-urlencoded", options: {} }, + { name: "a multipart XHR post", enctype: "multipart/form-data", options: {} }, + { name: "an iframe upload", enctype: "multipart/form-data", options: { iframe: true } }, +]; + +// Known failures: the plugin fails where the native submit posts. Each has an ID and a matcher; +// the test then pins the failure, so a fix makes it fail until the entry is removed. +const KNOWN_FAILURES = []; + +test.describe("seeded forms posted end to end", () => { + test.beforeEach(async ({ page }) => { + await openPage(page); + }); + + for (const mode of MODES) { + for (const seed of SEEDS) { + test(`when the form of seed ${seed} is sent as ${mode.name}, it should reach the server as a native submit does`, async ({ + page, + request, + }, testInfo) => { + const id = requestId(testInfo); + const form = await page.evaluate( + ([s, attributes]) => window.e2e.generate(s, attributes), + [seed, { action: `/r/${id}/ok`, method: "post", enctype: mode.enctype }] + ); + + const { native, plugin, result } = await submitBoth(page, request, id, mode.options); + + const known = KNOWN_FAILURES.filter((k) => k.matches(result, mode)); + if (known.length) { + testInfo.annotations.push({ type: "known failure", description: known[0].id }); + expect(plugin).toBeNull(); + expect(result.calls).toEqual(["error", "complete"]); + return; + } + const context = [ + `seed ${seed}, ${mode.name}`, + `form: ${form.html}`, + `plugin ${plugin.headers["content-type"]}: ${JSON.stringify(entries(sent(plugin)))}`, + `native ${native.headers["content-type"]}: ${JSON.stringify(entries(sent(native)))}`, + ].join("\n"); + expect(result.calls, `${context}\n${result.error}`).toEqual(["success", "complete"]); + expect(plugin.method, context).toBe("POST"); + if (mode.enctype === "multipart/form-data") { + expect(encoding(plugin), context).toBe("multipart"); + } + await expectSameFields(page, native, plugin, context); + }); + } + } +}); diff --git a/test/e2e/server.mjs b/test/e2e/server.mjs new file mode 100644 index 00000000..2fc16753 --- /dev/null +++ b/test/e2e/server.mjs @@ -0,0 +1,210 @@ +// End-to-end test server: serves the built plugin, jQuery and the fixture page, records every +// request under /r/ (method, url, headers, raw body and the parsed fields) and answers it with a +// named response. No framework: bodies are parsed with the platform's Request#formData(). +// +// Environment: E2E_PORT (default 4310), JQUERY_FILE (classic jQuery build, default jQuery 3), +// JQUERY_FORM_DIST (directory holding jquery.form.js, default dist), JQUERY_FORM_PACK_DIR (the +// installed tarball from scripts/pack-fixture.mjs, default .pack). +import { createServer } from "node:http"; +import { dirname, resolve } from "node:path"; +import { existsSync } from "node:fs"; +import { readFile } from "node:fs/promises"; + +const root = resolve(import.meta.dirname, "../.."); +const port = Number(process.env.E2E_PORT || 4310); +const jqueryFile = resolve(root, process.env.JQUERY_FILE || "node_modules/jquery/dist/jquery.js"); +const distDir = resolve(root, process.env.JQUERY_FORM_DIST || "dist"); +const packageDir = resolve( + root, + process.env.JQUERY_FORM_PACK_DIR || ".pack", + "jquery-3.7.1/node_modules/jquery-form" +); +// jQuery's own module build when it has one (jQuery 4), else a module that exports the global. +const jqueryModule = resolve(dirname(jqueryFile), "../dist-module/jquery.module.js"); + +const files = { + "/jquery.js": [jqueryFile, "text/javascript"], + "/jquery.form.js": [resolve(distDir, "jquery.form.js"), "text/javascript"], + "/oracle-forms.js": [resolve(root, "test/shared/oracle-forms.js"), "text/javascript"], + "/harness.js": [resolve(root, "test/e2e/harness.js"), "text/javascript"], + "/published.js": [resolve(root, "test/e2e/published.js"), "text/javascript"], + "/require.js": [resolve(root, "node_modules/requirejs/require.js"), "text/javascript"], + "/jquery.module.js": [jqueryModule, "text/javascript"], +}; + +const page = ` + + + + jquery-form e2e + + + + + + +
+ + +`; + +// Published-file pages: /published/[?min], loading the installed package by the entry +// points its package.json names (main, browser for the minified build, module). +async function publishedPage(loader, min) { + const manifest = JSON.parse(await readFile(resolve(packageDir, "package.json"), "utf8")); + const classic = "/pkg/" + (min ? manifest.jsdelivr : manifest.main); + const hasModule = existsSync(jqueryModule); + const loaders = { + script: ` + + + `, + amd: ` + + `, + esm: ` + ${hasModule ? "" : ''} + + `, + }; + return ` + + + + jquery-form published files + ${loaders[loader]} + + +
+ + +`; +} + +// Named responses: /r//[/...]. +const responses = { + ok: [200, "text/plain; charset=utf-8", "ok"], + json: [200, "application/json; charset=utf-8", '{"ok":true,"text":"ü"}'], + xml: [200, "application/xml; charset=utf-8", 'ü'], + html: [200, "text/html; charset=utf-8", '

ü

'], + script: [ + 200, + "text/javascript; charset=utf-8", + "window.e2eScriptRuns = (window.e2eScriptRuns || 0) + 1;", + ], + text: [200, "text/plain; charset=utf-8", "plain ü"], + "textarea-json": [200, "text/html; charset=utf-8", ''], + "status-404": [404, "text/plain; charset=utf-8", "missing"], + "status-500": [500, "text/plain; charset=utf-8", "broken"], +}; + +// Recorded requests by test id. +const recorded = new Map(); + +async function parseFields(method, url, headers, body) { + const type = headers["content-type"] || ""; + if (!/^(multipart\/form-data|application\/x-www-form-urlencoded)/i.test(type)) { + return null; + } + const request = new Request(url, { method, headers: { "content-type": type }, body }); + const fields = []; + for (const [name, value] of await request.formData()) { + if (typeof value === "string") { + fields.push({ name, kind: "text", value }); + } else { + const bytes = Buffer.from(await value.arrayBuffer()); + fields.push({ + name, + kind: "file", + value: value.name, + type: value.type, + base64: bytes.toString("base64"), + }); + } + } + return fields; +} + +async function record(req, url, body) { + const [, id, name] = url.pathname.split("/").slice(1); + const entry = { + method: req.method, + url: url.pathname + url.search, + headers: req.headers, + base64: body.toString("base64"), + query: Array.from(url.searchParams, ([n, value]) => ({ name: n, kind: "text", value })), + fields: body.length ? await parseFields(req.method, url, req.headers, body) : null, + }; + if (!recorded.has(id)) { + recorded.set(id, []); + } + recorded.get(id).push(entry); + return responses[name] || responses.ok; +} + +function send(res, status, type, body) { + res.writeHead(status, { "Content-Type": type, "Cache-Control": "no-store" }); + res.end(body); +} + +const server = createServer(async (req, res) => { + try { + const url = new URL(req.url, `http://${req.headers.host}`); + const chunks = []; + for await (const chunk of req) { + chunks.push(chunk); + } + const body = Buffer.concat(chunks); + + if (url.pathname.startsWith("/r/")) { + const [status, type, text] = await record(req, url, body); + return send(res, status, type, text); + } + if (url.pathname === "/requests") { + return send( + res, + 200, + "application/json", + JSON.stringify(recorded.get(url.searchParams.get("id")) || []) + ); + } + if (url.pathname === "/" || url.pathname === "/page") { + return send(res, 200, "text/html; charset=utf-8", page); + } + if (url.pathname.startsWith("/published/")) { + const html = await publishedPage(url.pathname.slice(11), url.searchParams.has("min")); + return send(res, 200, "text/html; charset=utf-8", html); + } + if (url.pathname === "/jquery-global.js") { + return send(res, 200, "text/javascript", "export default window.jQuery;\n"); + } + if (url.pathname.startsWith("/pkg/")) { + const file = resolve(packageDir, url.pathname.slice(5)); + if (file.startsWith(packageDir + "/") && existsSync(file)) { + return send(res, 200, "text/javascript", await readFile(file)); + } + } + if (files[url.pathname]) { + const [file, type] = files[url.pathname]; + return send(res, 200, type, await readFile(file)); + } + return send(res, 404, "text/plain", "not found"); + } catch (error) { + return send(res, 500, "text/plain", String(error && error.stack)); + } +}); + +server.listen(port, "127.0.0.1", () => { + console.log(`e2e server on http://127.0.0.1:${port}`); +}); diff --git a/test/shared/oracle-forms.js b/test/shared/oracle-forms.js new file mode 100644 index 00000000..65316035 --- /dev/null +++ b/test/shared/oracle-forms.js @@ -0,0 +1,456 @@ +// Seeded random forms and the known differences between the plugin and native form submission. +// Shared by the serialization oracle (test/suite) and the end-to-end tests (test/e2e), which loads +// this file in the page as a module: browser globals only, no imports. + +export const SEEDS = [ + 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765, 10946, 17711, + 28657, 46368, 75025, 121393, 196418, 317811, 514229, 832040, 1346269, 2178309, 3524578, 5702887, + 9227465, 14930352, 24157817, 39088169, 63245986, 102334155, 165580141, 7, 11, 17, 19, 23, 29, 31, + 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 97, 101, 103, +]; + +// mulberry32: a small seeded generator, so a failing seed replays the same form. +export function prng(seed) { + let state = seed >>> 0; + + const next = function () { + state = (state + 0x6d2b79f5) >>> 0; + let t = state; + t = Math.imul(t ^ (t >>> 15), t | 1); + t ^= t + Math.imul(t ^ (t >>> 7), t | 61); + return ((t ^ (t >>> 14)) >>> 0) / 4294967296; + }; + + return { + chance: (p) => next() < p, + int: (n) => Math.floor(next() * n), + pick: (list) => list[Math.floor(next() * list.length)], + }; +} + +const NAMES = ["a", "b", "c", "a b", "ü", "名前", "a[]", "a.b", "x=y", "&", "😀"]; +// Lone surrogates: rare; FormData and the plugin both send them as U+FFFD (class USV). +const LONE = ["q\uD800", "lone\uDC00"]; +const VALUES = [ + "", + "1", + "value", + " spaced out ", + "a&b=c", + "100%", + "1+1", + "é", + "日本語", + "😀", + "!'()*~", + "#ff0000", + "2024-02-29", + "42", + "x@example.com", +]; +const LINE_VALUES = ["one\rtwo", "one\ntwo", "one\r\ntwo", "\r\n\n\r"]; +const TEXT_TYPES = [ + "text", + "hidden", + "password", + "search", + "email", + "number", + "range", + "date", + "color", +]; +const FILE_NAMES = ["a.txt", "b c.txt", "ü.txt", "日本.txt"]; + +// Builds one random form (and its outside controls) inside `container`. +export function generateForm(seed, container) { + const rand = prng(seed); + const formId = "oracle-" + seed; + const counters = { file: 0, dir: 0, out: 0 }; + const outsideNames = []; + const form = document.createElement("form"); + form.id = formId; + const other = document.createElement("form"); + other.id = formId + "-other"; + + // Outside controls get their own names (out-N), so the semantic order class can find them. + function name(outside) { + if (outside) { + const outsideName = "out-" + counters.out++; + outsideNames.push(outsideName); + return outsideName; + } + return rand.chance(0.02) ? rand.pick(LONE) : rand.pick(NAMES); + } + + function value() { + return rand.chance(0.02) ? rand.pick(LONE) : rand.pick(VALUES); + } + + function input(type, outside) { + const el = document.createElement("input"); + el.type = type; + if (rand.chance(0.85)) { + el.name = name(outside); + } + return el; + } + + const makers = [ + function (outside) { + const el = input(rand.pick(TEXT_TYPES), outside); + if (rand.chance(0.8)) { + el.setAttribute("value", value()); + } + if (el.type === "hidden" && rand.chance(0.3)) { + el.value = rand.pick(LINE_VALUES); + } + if ((el.type === "text" || el.type === "search") && rand.chance(0.2)) { + el.setAttribute("dirname", "dir-" + counters.dir++); + } + return el; + }, + function (outside) { + const el = input(rand.pick(["checkbox", "radio"]), outside); + if (rand.chance(0.6)) { + el.setAttribute("value", value()); + } + el.checked = rand.chance(0.6); + return el; + }, + function (outside) { + const el = document.createElement("select"); + el.name = name(outside); + el.multiple = rand.chance(0.4); + let parent = el; + const count = rand.int(5); + for (let i = 0; i < count; i++) { + if (rand.chance(0.2)) { + parent = document.createElement("optgroup"); + parent.label = "g" + i; + parent.disabled = rand.chance(0.5); + el.appendChild(parent); + } + const option = document.createElement("option"); + option.text = rand.pick([" one ", "two", "日本", ""]); + if (rand.chance(0.6)) { + option.value = value(); + } + option.disabled = rand.chance(0.2); + parent.appendChild(option); + option.selected = rand.chance(0.4); + } + if (rand.chance(0.2)) { + el.selectedIndex = -1; + } + return el; + }, + function (outside) { + const el = document.createElement("textarea"); + el.name = name(outside); + el.value = rand.pick(LINE_VALUES.concat(VALUES)); + if (rand.chance(0.2)) { + el.setAttribute("dirname", "dir-" + counters.dir++); + } + return el; + }, + function (outside) { + const el = document.createElement("input"); + el.type = "file"; + el.name = "file-" + counters.file++; + if (outside) { + outsideNames.push(el.name); + } + const count = rand.int(3); + if (count) { + el.multiple = count > 1; + const transfer = new DataTransfer(); + for (let i = 0; i < count; i++) { + transfer.items.add(new File(["x"], rand.pick(FILE_NAMES), { type: "text/plain" })); + } + el.files = transfer.files; + } + return el; + }, + function (outside) { + const kind = rand.pick(["submit", "image", "button", "reset", "button-element"]); + let el; + if (kind === "button-element") { + el = document.createElement("button"); + el.type = rand.pick(["submit", "button", "reset", ""]); + if (rand.chance(0.9)) { + el.name = name(outside); + } + } else { + el = input(kind, outside); + } + if (rand.chance(0.7)) { + el.setAttribute("value", value()); + } + return el; + }, + function (outside) { + const el = input("hidden", outside); + if (!outside) { + el.name = "_charset_"; + } + el.setAttribute("value", value()); + return el; + }, + function (outside) { + const el = document.createElement(rand.pick(["output", "fieldset"])); + el.setAttribute("name", name(outside)); + el.textContent = "x"; + return el; + }, + ]; + + function control(outside) { + const el = rand.pick(makers)(outside); + el.disabled = el.disabled || rand.chance(0.1); + return el; + } + + // Fills a parent with controls, sometimes nested in a fieldset with a first legend. + function fill(parent, depth) { + const count = 1 + rand.int(6); + for (let i = 0; i < count; i++) { + if (depth < 2 && rand.chance(0.15)) { + const fieldset = document.createElement("fieldset"); + fieldset.disabled = rand.chance(0.5); + if (rand.chance(0.6)) { + const legend = document.createElement("legend"); + legend.appendChild(control(false)); + fieldset.appendChild(legend); + } + fill(fieldset, depth + 1); + parent.appendChild(fieldset); + continue; + } + const el = control(false); + if (rand.chance(0.08)) { + el.setAttribute("form", rand.pick([other.id, "oracle-nowhere", formId])); + } + parent.appendChild(el); + } + } + + fill(form, 0); + if (rand.chance(0.5)) { + form.appendChild(makers[5](false)); + } + + const before = rand.int(3); + const after = rand.int(3); + for (let i = 0; i < before; i++) { + const el = control(true); + el.setAttribute("form", formId); + container.appendChild(el); + } + container.appendChild(form); + container.appendChild(other); + for (let i = 0; i < after; i++) { + const el = control(true); + el.setAttribute("form", formId); + container.appendChild(el); + } + + // The submitter: one of the form's submit buttons, when it has any. + const submitters = Array.prototype.filter.call( + document.querySelectorAll("input, button"), + (el) => el.form === form && (el.type === "submit" || el.type === "image") + ); + const submitter = submitters.length && rand.chance(0.85) ? rand.pick(submitters) : null; + + return { form: form, submitter: submitter, outsideNames: outsideNames }; +} + +// [name, kind, value]: kind "file" holds the file name, kind "text" a string. +export function pluginEntries(fields) { + return fields.map(function (field) { + if (field.value instanceof File) { + return [field.name, "file", field.value.name]; + } + if (field.type === "file") { + return [field.name, "file", ""]; + } + return [field.name, "text", String(field.value)]; + }); +} + +export function nativeEntries(formData) { + return Array.from(formData.entries()).map(function (entry) { + return entry[1] instanceof File + ? [entry[0], "file", entry[1].name] + : [entry[0], "text", entry[1]]; + }); +} + +export function toWellFormed(text) { + return text.replace( + /[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(^|[^\uD800-\uDBFF])[\uDC00-\uDFFF]/g, + function (match, lead) { + return typeof lead === "string" ? lead + "\uFFFD" : "\uFFFD"; + } + ); +} + +export function isImage(el) { + return !!el && el.tagName === "INPUT" && el.type === "image"; +} + +// Known differences between the plugin and FormData. Each has an ID; `normalize` maps +// { plugin, native } entry lists to lists where that class no longer differs. +export const KNOWN_DIFFERENCES = [ + { + id: "USV", + description: "FormData replaces lone surrogates in names and values with U+FFFD", + normalize: (pair) => ({ + plugin: pair.plugin.map((e) => [toWellFormed(e[0]), e[1], toWellFormed(e[2])]), + native: pair.native, + }), + }, + { + id: "CRLF", + description: "the plugin sends line breaks as CRLF; FormData keeps them as the value has them", + normalize: (pair) => { + const lines = (e) => [e[0], e[1], e[1] === "text" ? e[2].replace(/\r\n|\r|\n/g, "\n") : e[2]]; + return { plugin: pair.plugin.map(lines), native: pair.native.map(lines) }; + }, + }, + { + id: "CHARSET", + description: "FormData sends a hidden _charset_ control's value as the document encoding", + normalize: (pair) => ({ + plugin: pair.plugin.map((e) => (e[0] === "_charset_" ? [e[0], e[1], "UTF-8"] : e)), + native: pair.native, + }), + }, + { + id: "DIRNAME", + description: "FormData adds a dirname field for text inputs and textareas; the plugin does not", + normalize: (pair) => ({ + plugin: pair.plugin, + native: pair.native.filter((e) => !/^dir-\d+$/.test(e[0])), + }), + }, + { + id: "SUBMIT-LABEL", + description: + 'FormData sends the default label of an input submitter without a value; the plugin sends ""', + normalize: (pair, ctx) => { + const sub = ctx.submitter; + if (!sub || sub.tagName !== "INPUT" || sub.type !== "submit" || sub.hasAttribute("value")) { + return pair; + } + return { + plugin: pair.plugin, + native: pair.native.map((e) => + e[0] === sub.name && /^Submit( Query)?$/.test(e[2]) ? [e[0], e[1], ""] : e + ), + }; + }, + }, + { + id: "IMG-VALUE", + description: "the plugin sends a clicked image button's name=value before its coordinates", + normalize: (pair, ctx) => { + if (!isImage(ctx.submitter) || !ctx.submitter.name) { + return pair; + } + const n = ctx.submitter.name; + return { + plugin: pair.plugin.filter( + (e, i) => !(e[0] === n && pair.plugin[i + 1] && pair.plugin[i + 1][0] === n + ".x") + ), + native: pair.native, + }; + }, + }, + { + id: "IMG-UNNAMED", + description: "FormData sends x and y for an unnamed image submitter; the plugin sends nothing", + normalize: (pair, ctx) => { + if (!isImage(ctx.submitter) || ctx.submitter.name || ctx.submitter.disabled) { + return pair; + } + return { + plugin: pair.plugin, + native: pair.native.filter((e) => e[0] !== "x" && e[0] !== "y"), + }; + }, + }, + { + id: "IMG-ORDER", + description: "without semantic, the plugin appends the clicked image's fields last", + normalize: (pair, ctx) => { + if (ctx.semantic || !isImage(ctx.submitter) || !ctx.submitter.name) { + return pair; + } + const n = ctx.submitter.name; + const last = (list) => { + const coords = list.filter((e) => e[0] === n + ".x" || e[0] === n + ".y"); + return list.filter((e) => coords.indexOf(e) < 0).concat(coords); + }; + return { plugin: last(pair.plugin), native: last(pair.native) }; + }, + }, + { + id: "SEM-ORDER", + description: "with semantic, the plugin sends outside controls (form=id) after the form's own", + normalize: (pair, ctx) => { + if (!ctx.semantic) { + return pair; + } + const outsideLast = (list) => { + const outside = list.filter( + (e) => ctx.outsideNames.indexOf(e[0].replace(/\.[xy]$/, "")) >= 0 + ); + return list.filter((e) => outside.indexOf(e) < 0).concat(outside); + }; + return { plugin: pair.plugin, native: outsideLast(pair.native) }; + }, + }, +]; + +// Applies every known class to { plugin, native } entry lists. +export function applyKnownDifferences(plugin, native, ctx) { + let pair = { plugin: plugin, native: native }; + KNOWN_DIFFERENCES.forEach(function (known) { + pair = known.normalize(pair, ctx); + }); + return pair; +} + +export function formatEntries(list) { + return list.map((e) => JSON.stringify(e)).join("\n "); +} + +export function canonicalQuery(query) { + if (!query) { + return []; + } + return query.split("&").map(function (pair) { + const parts = pair.split("="); + const decode = (part) => decodeURIComponent((part || "").replace(/\+/g, " ")); + return [decode(parts[0]), "text", decode(parts.slice(1).join("="))]; + }); +} + +let submitterArgumentSupported = null; + +// FormData(form, submitter) arrived after FormData(form); older engines ignore the argument. +export function supportsSubmitterArgument() { + if (submitterArgumentSupported === null) { + const form = document.createElement("form"); + const button = document.createElement("button"); + button.name = "probe"; + form.appendChild(button); + try { + submitterArgumentSupported = new FormData(form, button).has("probe"); + } catch { + submitterArgumentSupported = false; + } + } + return submitterArgumentSupported; +} diff --git a/test/suite/ajax-form.test.js b/test/suite/ajax-form.test.js index 18241be1..87914ea8 100644 --- a/test/suite/ajax-form.test.js +++ b/test/suite/ajax-form.test.js @@ -123,6 +123,14 @@ describe("form", function () { } }); + it("should not queue an empty selection once the DOM is ready", function () { + const $empty = $(".missing-ready-form"); + + const warnings = recordDeprecations(true, () => $empty.ajaxForm()); + + assert.isFalse(warnings.some((text) => text.includes("queuing"))); + }); + it("should return an empty selection without binding handlers", function () { const $missing = $(".missing-ajax-form"); @@ -479,6 +487,23 @@ describe("form", function () { }); }); + it("should not send a button clicked before the click window ended", async function () { + const $form = $( + '
' + ).appendTo("#main"); + $form.on("submit", false); + $form.ajaxForm(); + $form.find("button").trigger("click"); + await new Promise((resolve) => setTimeout(resolve, 120)); + + const requests = await withAjaxCapture(async function (requests) { + $form.ajaxSubmit(); + return requests; + }); + + assert.strictEqual(requests[0].data, ""); + }); + it("should call beforeSubmit and then success when the submit button is clicked", async function () { const opts = {}; @@ -902,6 +927,18 @@ describe("form", function () { ); }); + it("should name a selector to pass instead in the warning", function () { + const $form = $("
").appendTo("#main"); + + $form.ajaxForm({ delegation: true }); + + const expected = $form.selector === undefined ? 1 : 0; + assert.strictEqual( + warnings.filter((message) => message.includes('delegation: "form.ajax"')).length, + expected + ); + }); + it("should not warn when delegation is a selector", function () { $().ajaxForm({ delegation: ".scoped-ajax-form" }); @@ -1179,6 +1216,21 @@ describe("form", function () { ); }); + it("should keep other selectors bound when a selector is named like an object member", async function () { + const $form = $('
').appendTo("#main"); + + const calls = await withAjaxSubmitStub(async function (calls) { + $().ajaxForm({ delegation: ".scoped-ajax-form" }); + $().ajaxForm({ delegation: "constructor" }); + $form.trigger("submit"); + $().ajaxFormUnbind("constructor"); + $().ajaxFormUnbind(".scoped-ajax-form"); + return calls; + }); + + assert.strictEqual(calls.length, 1); + }); + describe("without Element.prototype.closest", function () { let closest; @@ -2062,6 +2114,18 @@ describe("form", function () { $(document).off(".form-plugin"); }); + it("should leave the page's own document handlers in place", function () { + let clicks = 0; + $(document).on("click.page-handler", () => clicks++); + $().ajaxForm({ delegation: ".scoped-ajax-form" }); + + $().ajaxFormUnbind(); + $(document).trigger("click"); + $(document).off("click.page-handler"); + + assert.strictEqual(clicks, 1); + }); + it("should keep a delegation selector working when another form is bound directly", async function () { const $scoped = $('
').appendTo("#main"); const $direct = $("
").appendTo("#main"); diff --git a/test/suite/diagnostics.test.js b/test/suite/diagnostics.test.js index 122fbea2..ff47652a 100644 --- a/test/suite/diagnostics.test.js +++ b/test/suite/diagnostics.test.js @@ -1,5 +1,5 @@ import { assert, describe, it } from "vitest"; -import { beforeJQuery35, deprecate, deprecateOldJQuery } from "../../src/diagnostics.js"; +import { beforeJQuery35, deprecate, deprecateOldJQuery, log } from "../../src/diagnostics.js"; import { recordDeprecations, resetFixture } from "./helpers.js"; describe("form", function () { @@ -54,6 +54,22 @@ describe("form", function () { assert.doesNotThrow(run); }); + it("should prefix the message and join its parts without a separator", function () { + const logged = []; + const consoleLog = console.log; + console.log = (text) => logged.push(text); + $.fn.ajaxSubmit.debug = true; + + try { + log("state = ", "complete", 1); + } finally { + $.fn.ajaxSubmit.debug = false; + console.log = consoleLog; + } + + assert.deepEqual(logged, ["[jquery.form] state = complete1"]); + }); + it("should stay silent when debug is disabled", function () { const logged = []; const log = console.log; @@ -181,5 +197,186 @@ describe("form", function () { assert.deepEqual(warnings, []); }); + + it("should prefix a deprecation warning with the plugin name", function () { + const warnings = recordDeprecations(true, () => deprecate("test-prefix", "a message")); + + assert.deepEqual(warnings, ["[jquery.form] a message (removed in 5.0)"]); + }); + + describe("when a page replaces $.fieldValue", function () { + function withReplacedFieldValue(run) { + const saved = $.fieldValue; + $.fieldValue = () => "over"; + + try { + return run(); + } finally { + $.fieldValue = saved; + } + } + + function aboutFieldValue(warnings) { + return warnings.filter((text) => text.includes("$.fieldValue")); + } + + it("should warn once, naming valHooks, when formToArray serializes under debug, and still use the replacement", function () { + const $form = $('
'); + let fields; + + const warnings = recordDeprecations(true, function () { + withReplacedFieldValue(function () { + fields = $form.formToArray(); + }); + }); + + assert.deepEqual(warnings, [ + "[jquery.form] replacing $.fieldValue to change what is serialized is deprecated, " + + "use jQuery valHooks (removed in 5.0)", + ]); + assert.deepEqual( + fields.map((field) => field.value), + ["over", "over"] + ); + }); + + it("should stay silent when formToArray serializes with debug off", function () { + const $form = $('
'); + + const warnings = recordDeprecations(false, function () { + withReplacedFieldValue(() => $form.formToArray()); + }); + + assert.deepEqual(warnings, []); + }); + + it("should not warn while $.fieldValue is the plugin's own", function () { + const $form = $('
'); + $form.appendTo("#main"); + + const warnings = recordDeprecations(true, function () { + $form.formToArray(); + $form.formSerialize(); + $form.find("input").fieldSerialize(); + $form.ajaxSubmit({ beforeSubmit: () => false }); + }); + + assert.deepEqual(aboutFieldValue(warnings), []); + }); + + it("should warn only once per page across repeated serializations", function () { + const $form = $('
'); + $form.appendTo("#main"); + + const warnings = recordDeprecations(true, function () { + withReplacedFieldValue(function () { + $form.formToArray(); + $form.formToArray(); + $form.formSerialize(); + $form.find("input").fieldSerialize(); + $form.ajaxSubmit({ beforeSubmit: () => false }); + }); + }); + + assert.strictEqual(aboutFieldValue(warnings).length, 1); + }); + + it("should warn when formSerialize serializes under debug", function () { + const $form = $('
'); + let serialized; + + const warnings = recordDeprecations(true, function () { + withReplacedFieldValue(function () { + serialized = $form.formSerialize(); + }); + }); + + assert.strictEqual(aboutFieldValue(warnings).length, 1); + assert.strictEqual(serialized, "a=over"); + }); + + it("should warn when fieldSerialize serializes under debug", function () { + const $input = $(''); + let serialized; + + const warnings = recordDeprecations(true, function () { + withReplacedFieldValue(function () { + serialized = $input.fieldSerialize(); + }); + }); + + assert.strictEqual(aboutFieldValue(warnings).length, 1); + assert.strictEqual(serialized, "a=over"); + }); + + it("should warn when ajaxSubmit serializes under debug", function () { + const $form = $('
'); + $form.appendTo("#main"); + let fields; + + const warnings = recordDeprecations(true, function () { + withReplacedFieldValue(function () { + $form.ajaxSubmit({ + beforeSubmit: function (sent) { + fields = sent; + return false; + }, + }); + }); + }); + + assert.strictEqual(aboutFieldValue(warnings).length, 1); + assert.strictEqual(fields[0].value, "over"); + }); + + it("should not warn when fieldValue reads through the replacement", function () { + const $input = $(''); + let values; + + const warnings = recordDeprecations(true, function () { + withReplacedFieldValue(function () { + values = $input.fieldValue(); + }); + }); + + assert.deepEqual(warnings, []); + assert.deepEqual(values, ["over"]); + }); + }); + + describe("on a page whose jQuery is older than 3.5", function () { + function withJQueryVersion(version, run) { + const actual = $.fn.jquery; + $.fn.jquery = version; + + try { + return run(); + } finally { + $.fn.jquery = actual; + } + } + + it("should warn on the first ajaxSubmit under debug", function () { + const $form = $('
').appendTo("#main"); + + const warnings = withJQueryVersion("3.4.1", () => + recordDeprecations(true, () => $form.ajaxSubmit({ beforeSubmit: () => false })) + ); + + assert.strictEqual(warnings.length, 1); + assert.include(warnings[0], "jQuery 3.4.1"); + }); + + it("should warn on the first ajaxForm under debug", function () { + const $form = $("
").appendTo("#main"); + + const warnings = withJQueryVersion("3.4.1", () => + recordDeprecations(true, () => $form.ajaxForm()) + ); + + assert.strictEqual(warnings.length, 1); + assert.include(warnings[0], "jQuery 3.4.1"); + }); + }); }); }); diff --git a/test/suite/field-helpers.test.js b/test/suite/field-helpers.test.js index 2cc8c3f2..5bde2f2a 100644 --- a/test/suite/field-helpers.test.js +++ b/test/suite/field-helpers.test.js @@ -226,6 +226,20 @@ describe("form", function () { assert.strictEqual($label.find("input").val(), "nested"); }); + it("should reset every selected element after a label or a container", function () { + const $label = $('').appendTo("#main"); + const $div = $('
').appendTo("#main"); + const $last = $('').appendTo("#main"); + $("#main input").val("changed"); + + $label.add($div).add($last).resetForm(); + + assert.deepEqual( + [$label.find("input").val(), $div.find("input").val(), $last.val()], + ["in label", "in div", "last"] + ); + }); + // #600: the document and text nodes have no tag name. it("should reset the fields of a document and skip text nodes", function () { const $input = $('').appendTo("#main").val("changed"); diff --git a/test/suite/form-members.test.js b/test/suite/form-members.test.js index 03c34a04..b05cfcdb 100644 --- a/test/suite/form-members.test.js +++ b/test/suite/form-members.test.js @@ -1,5 +1,6 @@ import { assert, describe, it } from "vitest"; import { callFormMethod, formMember } from "../../src/form-members.js"; +import { formAttribute } from "../../src/form-attributes.js"; describe("form members", function () { describe("formMember", function () { @@ -75,4 +76,14 @@ describe("form members", function () { assert.strictEqual(valid, false); }); }); + + describe("formAttribute", function () { + it("should return undefined for an absent attribute, as jQuery's attr does", function () { + const form = $('
')[0]; + + const value = formAttribute(form, "id"); + + assert.strictEqual(value, undefined); + }); + }); }); diff --git a/test/suite/iframe-response.test.js b/test/suite/iframe-response.test.js index b46c632a..af93925c 100644 --- a/test/suite/iframe-response.test.js +++ b/test/suite/iframe-response.test.js @@ -57,6 +57,33 @@ describe("iframe response reader", function () { assert.strictEqual(xhr.getResponseHeader("Content-Type"), "xml"); }); + it("should keep the markup of an HTML response that contains a textarea", function () { + const doc = parse(""); + const xhr = mockXhr(); + + const result = readResponse(doc, xhr, { dataType: "html" }, noRetry); + + assert.strictEqual(result.data, ""); + }); + + it("should keep the body markup with the textarea option when no textarea is found", function () { + const doc = parse("bold"); + const xhr = mockXhr(); + + const result = readResponse(doc, xhr, { dataType: "html", textarea: true }, noRetry); + + assert.strictEqual(result.data, "bold"); + }); + + it("should parse JSON from the body text when there is no pre or textarea", function () { + const doc = parse('{"a":"x & y"}'); + const xhr = mockXhr(); + + const result = readResponse(doc, xhr, { dataType: "json" }, noRetry); + + assert.deepEqual(result.data, { a: "x & y" }); + }); + it("should parse JSON embedded in a textarea", function () { const doc = parse(''); const xhr = mockXhr(); diff --git a/test/suite/iframe-transport.test.js b/test/suite/iframe-transport.test.js index 9442e5fc..202af635 100644 --- a/test/suite/iframe-transport.test.js +++ b/test/suite/iframe-transport.test.js @@ -664,7 +664,8 @@ describe("form", function () { it("should set the iframe source as an attribute, not HTML", async function () { window.iframePayload = 0; - const iframeSrc = 'about:blank">'; + // WebKit's browser process crashes on any other about: URL, so the payload sits in a fragment. + const iframeSrc = 'about:blank#">'; const $form = createIframeForm("ajax/iframe-text.html"); const seen = await submitAndAbort($form, { iframeSrc: iframeSrc }); @@ -1545,6 +1546,41 @@ describe("form", function () { assert.include(events, "ajaxStop"); }); + it("should build no elements from an iframeTarget given as an HTML string", async function () { + const $form = createIframeForm("ajax/iframe-text.html"); + $form[0].submit = function () {}; + window.__frameHtml = 0; + $.active = 0; + + try { + $form.ajaxSubmit({ + iframe: true, + forceSync: true, + iframeTarget: '', + error: function () {}, + }); + } catch { + // an iframeTarget that matches nothing throws here + } + await new Promise((resolve) => setTimeout(resolve, 100)); + + assert.strictEqual(window.__frameHtml, 0); + assert.strictEqual($.active, 0); + }); + + it("should find an iframeTarget selector with a tag in an attribute value", function () { + const $target = $('').appendTo("#main"); + const $form = createIframeForm("ajax/iframe-text.html"); + + $form.ajaxSubmit({ + iframe: true, + iframeTarget: 'iframe[title=""]', + beforeSend: () => false, + }); + + assert.match($target.attr("name"), /^jqFormIO\d+$/); + }); + describe("when the frame is not in the document", function () { const message = "jquery.form: the upload frame is not in the document"; @@ -1843,6 +1879,41 @@ describe("form", function () { assert.strictEqual($("iframe").length, frames); }); + it("should pass the xhr, the settings and canceled to ajaxError when beforeSend vetoes", function () { + const $form = createIframeForm("ajax/iframe-text.html"); + let seen; + $(document).on("ajaxError.ifrlog", function (event, xhr, settings, reason) { + seen = [typeof xhr.abort, settings.iframe, reason]; + }); + + $form.ajaxSubmit({ iframe: true, beforeSend: () => false }); + + assert.deepEqual(seen, ["function", true, "canceled"]); + }); + + it("should fire no global events when beforeSend vetoes with global false", function () { + const $form = createIframeForm("ajax/iframe-text.html"); + const events = []; + recordGlobalEvents(events); + + $form.ajaxSubmit({ iframe: true, global: false, beforeSend: () => false }); + + assert.deepEqual(events, []); + }); + + it("should ignore an abort after beforeSend vetoed", function () { + const $form = createIframeForm("ajax/iframe-text.html"); + const events = []; + let errors = 0; + $form.ajaxSubmit({ iframe: true, beforeSend: () => false, error: () => errors++ }); + recordGlobalEvents(events); + + $form.data("jqxhr").abort(); + + assert.strictEqual(errors, 0); + assert.deepEqual(events, []); + }); + it("should end the global events without ajaxSend when beforeSend vetoes", function () { const $form = createIframeForm("ajax/iframe-text.html"); const events = []; @@ -1928,6 +1999,21 @@ describe("form", function () { assert.deepEqual(fields, [["choice", "picked"]]); }); + it("should post a clicked button's lone surrogate as U+FFFD", function () { + const $form = createIframeForm("ajax/iframe-text.html"); + const button = $('