diff --git a/wp-includes/js/dist/vendor/wp-polyfill-dom-rect.js b/wp-includes/js/dist/vendor/wp-polyfill-dom-rect.js index 9ed8ce994e..ee123bed91 100644 --- a/wp-includes/js/dist/vendor/wp-polyfill-dom-rect.js +++ b/wp-includes/js/dist/vendor/wp-polyfill-dom-rect.js @@ -4,7 +4,7 @@ function number(v) { return v === undefined ? 0 : Number(v); } - + function different(u, v) { return u !== v && !(isNaN(u) && isNaN(v)); } @@ -96,6 +96,6 @@ } }); } - + global.DOMRect = DOMRect; }(self)); diff --git a/wp-includes/js/dist/vendor/wp-polyfill-formdata.js b/wp-includes/js/dist/vendor/wp-polyfill-formdata.js index 8f06c0707a..8e7366059e 100644 --- a/wp-includes/js/dist/vendor/wp-polyfill-formdata.js +++ b/wp-includes/js/dist/vendor/wp-polyfill-formdata.js @@ -1,3 +1,5 @@ +/* formdata-polyfill. MIT License. Jimmy Wärting */ + /* global FormData self Blob File */ /* eslint-disable no-inner-declarations */ @@ -40,16 +42,13 @@ if (typeof Blob !== 'undefined' && (typeof FormData === 'undefined' || !FormData new File([], '') // eslint-disable-line } catch (a) { global.File = function File (b, d, c) { - const blob = new Blob(b, c) + const blob = new Blob(b, c || {}) const t = c && void 0 !== c.lastModified ? new Date(c.lastModified) : new Date() Object.defineProperties(blob, { name: { value: d }, - lastModifiedDate: { - value: t - }, lastModified: { value: +t }, @@ -70,50 +69,52 @@ if (typeof Blob !== 'undefined' && (typeof FormData === 'undefined' || !FormData } } - function normalizeValue ([name, value, filename]) { - if (value instanceof Blob) { - // Should always returns a new File instance - // console.assert(fd.get(x) !== fd.get(x)) - value = new File([value], filename, { - type: value.type, - lastModified: value.lastModified - }) - } - - return [name, value] - } - function ensureArgs (args, expected) { if (args.length < expected) { throw new TypeError(`${expected} argument required, but only ${args.length} present.`) } } + /** + * @param {string} name + * @param {string | undefined} filename + * @returns {[string, File|string]} + */ function normalizeArgs (name, value, filename) { - return value instanceof Blob - // normalize name and filename if adding an attachment - ? [String(name), value, filename !== undefined - ? filename + '' // Cast filename to string if 3th arg isn't undefined - : typeof value.name === 'string' // if name prop exist - ? value.name // Use File.name - : 'blob'] // otherwise fallback to Blob + if (value instanceof Blob) { + filename = filename !== undefined + ? String(filename + '') + : typeof value.name === 'string' + ? value.name + : 'blob' - // If no attachment, just cast the args to strings - : [String(name), String(value)] + if (value.name !== filename || Object.prototype.toString.call(value) === '[object Blob]') { + value = new File([value], filename) + } + return [String(name), value] + } + return [String(name), String(value)] } - // normalize linefeeds for textareas + // normalize line feeds for textarea // https://html.spec.whatwg.org/multipage/form-elements.html#textarea-line-break-normalisation-transformation function normalizeLinefeeds (value) { - return value.replace(/\r\n/g, '\n').replace(/\n/g, '\r\n') + return value.replace(/\r?\n|\r/g, '\r\n') } + /** + * @template T + * @param {ArrayLike} arr + * @param {{ (elm: T): void; }} cb + */ function each (arr, cb) { for (let i = 0; i < arr.length; i++) { cb(arr[i]) } } + const escape = str => str.replace(/\n/g, '%0A').replace(/\r/g, '%0D').replace(/"/g, '%22') + /** * @implements {Iterable} */ @@ -121,14 +122,14 @@ if (typeof Blob !== 'undefined' && (typeof FormData === 'undefined' || !FormData /** * FormData class * - * @param {HTMLElement=} form + * @param {HTMLFormElement=} form */ constructor (form) { + /** @type {[string, string|File][]} */ this._data = [] const self = this - - form && each(form.elements, elm => { + form && each(form.elements, (/** @type {HTMLInputElement} */ elm) => { if ( !elm.name || elm.disabled || @@ -196,7 +197,7 @@ if (typeof Blob !== 'undefined' && (typeof FormData === 'undefined' || !FormData */ * entries () { for (var i = 0; i < this._data.length; i++) { - yield normalizeValue(this._data[i]) + yield this._data[i] } } @@ -205,7 +206,6 @@ if (typeof Blob !== 'undefined' && (typeof FormData === 'undefined' || !FormData * * @param {Function} callback Executed for each item with parameters (value, name, thisArg) * @param {Object=} thisArg `this` context for callback function - * @return {undefined} */ forEach (callback, thisArg) { ensureArgs(arguments, 1) @@ -216,7 +216,7 @@ if (typeof Blob !== 'undefined' && (typeof FormData === 'undefined' || !FormData /** * Return first field value given name - * or null if non existen + * or null if non existent * * @param {string} name Field name * @return {string|File|null} value Fields value @@ -227,7 +227,7 @@ if (typeof Blob !== 'undefined' && (typeof FormData === 'undefined' || !FormData name = String(name) for (let i = 0; i < entries.length; i++) { if (entries[i][0] === name) { - return normalizeValue(entries[i])[1] + return entries[i][1] } } return null @@ -244,7 +244,7 @@ if (typeof Blob !== 'undefined' && (typeof FormData === 'undefined' || !FormData const result = [] name = String(name) each(this._data, data => { - data[0] === name && result.push(normalizeValue(data)[1]) + data[0] === name && result.push(data[1]) }) return result @@ -284,17 +284,17 @@ if (typeof Blob !== 'undefined' && (typeof FormData === 'undefined' || !FormData * @param {string} name Filed name * @param {string} value Field value * @param {string=} filename Filename (optional) - * @return {undefined} */ set (name, value, filename) { ensureArgs(arguments, 2) name = String(name) + /** @type {[string, string|File][]} */ const result = [] const args = normalizeArgs(name, value, filename) let replace = true // - replace the first occurrence with same name - // - discards the remaning with same name + // - discards the remaining with same name // - while keeping the same order items where added each(this._data, data => { data[0] === name @@ -340,38 +340,23 @@ if (typeof Blob !== 'undefined' && (typeof FormData === 'undefined' || !FormData * @return {Blob} [description] */ ['_blob'] () { - const boundary = '----formdata-polyfill-' + Math.random() - const chunks = [] - - for (const [name, value] of this) { - chunks.push(`--${boundary}\r\n`) - - if (value instanceof Blob) { - chunks.push( - `Content-Disposition: form-data; name="${name}"; filename="${value.name}"\r\n` + - `Content-Type: ${value.type || 'application/octet-stream'}\r\n\r\n`, - value, - '\r\n' - ) - } else { - chunks.push( - `Content-Disposition: form-data; name="${name}"\r\n\r\n${value}\r\n` - ) - } - } - - chunks.push(`--${boundary}--`) - - return new Blob(chunks, { - type: 'multipart/form-data; boundary=' + boundary - }) + const boundary = '----formdata-polyfill-' + Math.random(), + chunks = [], + p = `--${boundary}\r\nContent-Disposition: form-data; name="` + this.forEach((value, name) => typeof value == 'string' + ? chunks.push(p + escape(normalizeLinefeeds(name)) + `"\r\n\r\n${normalizeLinefeeds(value)}\r\n`) + : chunks.push(p + escape(normalizeLinefeeds(name)) + `"; filename="${escape(value.name)}"\r\nContent-Type: ${value.type||"application/octet-stream"}\r\n\r\n`, value, `\r\n`)) + chunks.push(`--${boundary}--`) + return new Blob(chunks, { + type: "multipart/form-data; boundary=" + boundary + }) } /** * The class itself is iterable * alias for formdata.entries() * - * @return {Iterator} + * @return {Iterator} */ [Symbol.iterator] () { return this.entries() diff --git a/wp-includes/js/dist/vendor/wp-polyfill-formdata.min.js b/wp-includes/js/dist/vendor/wp-polyfill-formdata.min.js index a9dc52f55b..85188c4207 100644 --- a/wp-includes/js/dist/vendor/wp-polyfill-formdata.min.js +++ b/wp-includes/js/dist/vendor/wp-polyfill-formdata.min.js @@ -1 +1,2 @@ -!function(){var t;function e(t){var e=0;return function(){return e>>0)+"_",o=0;return function t(n){if(this instanceof t)throw new TypeError("Symbol is not a constructor");return new e(r+(n||"")+"_"+o++,n)}})),i("Symbol.iterator",(function(t){if(t)return t;t=Symbol("Symbol.iterator");for(var r="Array Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array".split(" "),i=0;i */ +!function(){var t;function e(t){var e=0;return function(){return e>>0)+"_",o=0;return function t(n){if(this instanceof t)throw new TypeError("Symbol is not a constructor");return new e(r+(n||"")+"_"+o++,n)}})),i("Symbol.iterator",(function(t){if(t)return t;t=Symbol("Symbol.iterator");for(var r="Array Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array".split(" "),i=0;i '2.29.2', 'lodash' => '4.17.19', 'wp-polyfill-fetch' => '3.6.2', - 'wp-polyfill-formdata' => '4.0.0', - 'wp-polyfill-node-contains' => '3.105.0', + 'wp-polyfill-formdata' => '4.0.10', + 'wp-polyfill-node-contains' => '4.0.0', 'wp-polyfill-url' => '3.6.4', - 'wp-polyfill-dom-rect' => '3.104.0', + 'wp-polyfill-dom-rect' => '4.0.0', 'wp-polyfill-element-closest' => '2.0.2', 'wp-polyfill-object-fit' => '2.3.5', 'wp-polyfill' => '3.15.0', diff --git a/wp-includes/version.php b/wp-includes/version.php index 69bb7325a2..b4552494e7 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.0-alpha-53164'; +$wp_version = '6.0-alpha-53165'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.