reiern70 commented on code in PR #1671:
URL: https://github.com/apache/wicket/pull/1671#discussion_r4325405668
##########
wicket-core/src/main/java/org/apache/wicket/markup/html/form/upload/resource/FileUploadToResourceField.js:
##########
@@ -19,10 +19,25 @@
'use strict';
- if (typeof(Wicket.FileUploadToResourceField) === 'object') {
+ if (typeof(Wicket.FileUploadToResourceField) === 'function') {
return;
}
+ // the keys of the errors, as the field knows them
+ const UPLOAD_TOO_LARGE = 'uploadTooLarge';
+ const UPLOAD_SINGLE_FILE_TOO_LARGE = 'uploadSingleFileTooLarge';
+ const UPLOAD_TOO_MANY_FILES = 'uploadTooManyFiles';
+ const UPLOAD_FAILED = 'uploadFailed';
+ const CONNECTION_LOST = 'uploadConnectionLost';
+ const UPLOAD_CANCELED = 'upload.canceled';
+
+ // the file lists of the fields, by field id: the text of the remove
buttons, by list id
+ const lists = {};
+
+ // the running uploads, by field id: the request, the files it sends and
the field it belongs
+ // to, which a new rendering of the field takes over
+ const uploads = {};
Review Comment:
Thanks, confirmed and fixed in 96da7c35de, which replaces 2439b81225 (the
#1669 commit the earlier replies cite): `uploads` is a null-prototype object
now, as you suggested.
`lists` next to it had the same problem, with a worse effect. For a field id
such as `constructor`, `addList` wrote the text of the remove buttons onto
`Object` itself (onto `Object.prototype` for `__proto__`). It then called
`Object.renderLists()` and threw, because `addList` and the drop zone read the
field from `Wicket.Timer[fieldId]`, which holds the inherited value until the
field is created. `lists` and its per-field maps have no prototype now either,
and both lookups only accept a `Wicket.FileUploadToResourceField`.
Tests: "a field whose id an object inherits starts its first upload" (your
case) and "a list added before its field, whose id an object inherits, shows
its files". Both fail on the previous revision and pass now, in Chrome and
Firefox, under both Ajax engines.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]