Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test the ClipboardEvent constructor #7857

Open
foolip opened this issue Oct 17, 2017 · 6 comments
Open

Test the ClipboardEvent constructor #7857

foolip opened this issue Oct 17, 2017 · 6 comments

Comments

@foolip
Copy link
Member

foolip commented Oct 17, 2017

See w3c/clipboard-apis#33 for context.

@guest271314
Copy link
Contributor

@foolip One interesting aspect of new ClipboardEvent() that found at Firefox 57 is that when the .files property is set at the .dataTransfer object using .items .add() method, then that .files object is set at an <input type="file"> .files property whatwg/html#2866, if the <input type="file"> element .value is set to null the File objects at both the .files property of .dataTransfer and of <input type="file"> element are removed from the FileList object. Not certain if that is the expected result according to a specification?

      const input = document.createElement("input");
      const dt = new ClipboardEvent("").clipboardData;
      const file = new File(["a"], "a.txt", {type:"text/plain"});
      input.type = "file";
      dt.items.add(file);
      console.log(dt.files);
      input.files = dt.files;
      console.log(input.files, dt.files);
      input.value = null;
      console.log(input.files, dt.files);

plnkr http://plnkr.co/edit/AVeKTSKxOwb8jA4keE2m?p=preview

@foolip
Copy link
Member Author

foolip commented Nov 24, 2017

@guest271314 I'm not sure actually if that's per spec, but did you try the same code in different browsers to see if it's interoperable, or does only Firefox have it so far?

@jimmywarting
Copy link
Contributor

jimmywarting commented Dec 4, 2017

@guest271314 Oh so long i have been waiting for input.files to be settable finally there is a way to do it. wish there was a nicer way to deal with it doe...

@guest271314
Copy link
Contributor

guest271314 commented Dec 17, 2017

@foolip new ClipboardEvent("").clipboardData returns null at Chromium/Chrome. new DataTransfer() is not yet supported at Firefox.

@guest271314
Copy link
Contributor

@jimmywarting Does whatwg/html#3269 (comment) help?

@jimmywarting
Copy link
Contributor

Well, i don't need it now but i will remember this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants