External Libraries: Update polyfill libraries.
This updates two polyfill libraries to their latest versions. - `polyfill-library` from `3.105.0` to `4.0.0`. - `formdata-polyfill` from `4.0.0` to `4.0.10`. This will affect the following script handles: - `wp-polyfill-formdata` - `wp-polyfill-node-contains` - `wp-polyfill-dom-rect` These polyfills are no longer used by WordPress Core, but are kept up to date as a courtesy for any plugins or themes still requiring them. See #55547. Built from https://develop.svn.wordpress.org/trunk@53165 git-svn-id: http://core.svn.wordpress.org/trunk@52754 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
35005412d0
commit
43ca7ac938
|
@ -1,3 +1,5 @@
|
|||
/* formdata-polyfill. MIT License. Jimmy Wärting <https://jimmy.warting.se/opensource> */
|
||||
|
||||
/* 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<T>} 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()
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -109,10 +109,10 @@ function wp_default_packages_vendor( $scripts ) {
|
|||
'moment' => '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',
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Reference in New Issue