Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upImplement filter for file-type input's accept attribute #11757
Conversation
highfive
commented
Jun 16, 2016
|
Heads up! This PR modifies the following files:
|
|
cc @Manishearth |
|
|
| if let Some('.') = p.chars().nth(0) { | ||
| filter.push(FilterPattern(p[1..].to_string())); | ||
| } else { | ||
| if let Some(exts) = mime_guess::get_mime_extensions_str(p) { |
This comment has been minimized.
This comment has been minimized.
Manishearth
Jun 20, 2016
Member
There might be a better way of doing this by directly telling the OS the mime type. However, since it's not in the tfd api yet, we can just merge this for now.
This comment has been minimized.
This comment has been minimized.
izgzhen
Jun 20, 2016
Author
Contributor
Actually I am a bit surprised that OS might have a concept like MIME (thinking only Web has that)
This comment has been minimized.
This comment has been minimized.
Manishearth
Jun 20, 2016
Member
Oh, that's a good point. I think you can tell the OS "image files only" though I'm not sure. You can investigate that later if you want.
|
r=me post rebase |
2c8c953
to
74eb80d
|
@bors-servo r=Manishearth |
|
|
Implement filter for file-type input's accept attribute
Now the two sides are pasted together with the new version of `mime_guess` landed.
I tested this thing locally with stuff like this:
```html
<input id="input_file" type="file" accept=".doc,.docx,.xml,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document"></input>
<a onclick="open_file();">Click</a>
<script type="text/javascript">
function open_file() {
console.log("Open file");
document.getElementById("input_file").click();
}
</script>
```
Will WPT be able to handle this automatically?
---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes is related to #11131
<!-- Either: -->
- [ ] There are tests for these changes OR
- [ ] These changes do not require tests because _____
<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/11757)
<!-- Reviewable:end -->
|
|
izgzhen commentedJun 16, 2016
•
edited
Now the two sides are pasted together with the new version of
mime_guesslanded.I tested this thing locally with stuff like this:
Will WPT be able to handle this automatically?
Related to #11131
This change is