mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 19:37:35 +00:00
LibWeb: Reverse check for whether a FilesList index is supported
This fixes for..of iteration of a FilesList object.
This commit is contained in:
parent
c2ef506b4a
commit
0cc8698a62
3 changed files with 18 additions and 7 deletions
|
@ -1,7 +1,12 @@
|
||||||
Select file...file1 Select files...4 files selected. input1:
|
Select file...file1 Select files...4 files selected. input1:
|
||||||
file1: Contents for file1
|
file1 (index iteration): Contents for file1
|
||||||
|
file1 (for..of iteration): Contents for file1
|
||||||
input2:
|
input2:
|
||||||
file1: Contents for file1
|
file1 (index iteration): Contents for file1
|
||||||
file2: Contents for file2
|
file2 (index iteration): Contents for file2
|
||||||
file3: Contents for file3
|
file3 (index iteration): Contents for file3
|
||||||
file4: Contents for file4
|
file4 (index iteration): Contents for file4
|
||||||
|
file1 (for..of iteration): Contents for file1
|
||||||
|
file2 (for..of iteration): Contents for file2
|
||||||
|
file3 (for..of iteration): Contents for file3
|
||||||
|
file4 (for..of iteration): Contents for file4
|
||||||
|
|
|
@ -13,7 +13,13 @@
|
||||||
const file = input.files.item(i);
|
const file = input.files.item(i);
|
||||||
const text = await file.text();
|
const text = await file.text();
|
||||||
|
|
||||||
println(`${file.name}: ${text}`);
|
println(`${file.name} (index iteration): ${text}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (let file of input.files) {
|
||||||
|
const text = await file.text();
|
||||||
|
|
||||||
|
println(`${file.name} (for..of iteration): ${text}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
resolve();
|
resolve();
|
||||||
|
|
|
@ -41,7 +41,7 @@ bool FileList::is_supported_property_index(u32 index) const
|
||||||
if (m_files.is_empty())
|
if (m_files.is_empty())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return m_files.size() < index;
|
return index < m_files.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
WebIDL::ExceptionOr<JS::Value> FileList::item_value(size_t index) const
|
WebIDL::ExceptionOr<JS::Value> FileList::item_value(size_t index) const
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue