Issue #2458 - Make HTMLInputElement.files read-write

Resolves #2458
This commit is contained in:
Moonchild 2024-01-15 20:26:10 +01:00 committed by roytam1
commit 8b7021f216
3 changed files with 22 additions and 1 deletions

View file

@ -3105,6 +3105,26 @@ HTMLInputElement::GetFiles()
return mFileList;
}
void
HTMLInputElement::SetFiles(FileList* aFiles)
{
if (mType != NS_FORM_INPUT_FILE || !aFiles) {
return;
}
// Clear |mFileList| to omit |UpdateFileList|
if (mFileList) {
mFileList->Clear();
mFileList = nullptr;
}
// Update |mFilesOrDirectories|
SetFiles(aFiles, true);
// Update |mFileList| without copy
mFileList = aFiles;
}
/* static */ void
HTMLInputElement::HandleNumberControlSpin(void* aData)
{

View file

@ -474,6 +474,7 @@ public:
// XPCOM GetForm() is OK
FileList* GetFiles();
void SetFiles(FileList* aFiles);
// XPCOM GetFormAction() is OK
void SetFormAction(const nsAString& aValue, ErrorResult& aRv)

View file

@ -40,7 +40,7 @@ interface HTMLInputElement : HTMLElement {
attribute boolean disabled;
readonly attribute HTMLFormElement? form;
[Pure]
readonly attribute FileList? files;
attribute FileList? files;
[CEReactions, Pure, SetterThrows]
attribute DOMString formAction;
[CEReactions, Pure, SetterThrows]