content icon indicating copy to clipboard operation
content copied to clipboard

Example shows non-existent “img.file” attribute

Open santifoo opened this issue 3 years ago • 2 comments

MDN URL

https://developer.mozilla.org/en-US/docs/Web/API/File_API/Using_files_from_web_applications#example_showing_thumbnails_of_user-selected_images

What specific section or headline is this issue about?

example_showing_thumbnails_of_user-selected_images

What information was incorrect, unhelpful, or incomplete?

Uses img.file but attribute does not exist

What did you expect to see?

line should be removed

Do you have any supporting links, references, or citations?

No response

Do you have anything more you want to share?

No response

MDN metadata

Page report details
  • Folder: en-us/web/api/file_api/using_files_from_web_applications
  • MDN URL: https://developer.mozilla.org/en-US/docs/Web/API/File_API/Using_files_from_web_applications
  • GitHub URL: https://github.com/mdn/content/blob/main/files/en-us/web/api/file_api/using_files_from_web_applications/index.md
  • Last commit: https://github.com/mdn/content/commit/5d88855e1d963ca0b0c3c14aeaa6414f8386c64e
  • Document last modified: 2022-10-12T09:03:14.000Z

santifoo avatar Nov 03 '22 11:11 santifoo

Hi @santimirandarp, thanks for raising the issue.

It looks like the file attribute is being used later on in the guide. This is usage of a non-standard attribute to store some data like so:

const img = document.createElement('img');
img.classList.add('obj');
img.aCoolAttribute = 'path/to/file.jpg';
document.head.appendChild(img); 

image

Maybe usage of data attribute might be better:

https://developer.mozilla.org/en-US/docs/Learn/HTML/Howto/Use_data_attributes

bsmth avatar Nov 04 '22 18:11 bsmth

I see. Thanks for clarifying, I'd agree using a standard data attribute rather but may not be very important.

It was confusing to me bc I thought it had smth to do with the src attribute.

ghost avatar Nov 04 '22 18:11 ghost