GithubHelp home page GithubHelp logo

isabella232 / dropzone-polyfill Goto Github PK

View Code? Open in Web Editor NEW

This project forked from google/dropzone-polyfill

0.0 0.0 0.0 12 KB

Polyfill for the removed HTML5 dropzone attribute

License: Apache License 2.0

JavaScript 43.43% HTML 56.24% CSS 0.33%

dropzone-polyfill's Introduction

Polyfill for the removed HTML5 dropzone attribute

This is not an official Google product.

This is a polyfill intended to help sites impacted by the removal of webkitdropzone from Chromium.

Usage

If your Web application's drag-and-drop functionality works in Firefox, Edge, or any other browser that is not based on Blink or WebKit, stop reading now. You do not need this polyfill.

If you're still here, the quickest way to get your site working again is to download lib/dropzone-polyfill.js and include it in your site's JavaScript bundler, then call DropzonePolyfill.handleDom() after your DOM is ready. For example,

window.addEventListener('load', function() {
  DropzonePolyfill.handleDom();
}, false);

In the long run, you should switch to the imperative API for handling drops. This polyfill is way more complex than the code you'll have to write for your own application, due to the need of handling the entire dropzone syntax.

The code needed to replace webkitdropzone can be as simple as:

Limitations

In Safari and Firefox, the polyfill is not able to obtain the MIME type of dragged files at the time needed to implement the filters expressed by file: tokens in the dropzone attribute. The polyfill errs on the side of false positives, by having any dragged file match against any file: token.

For example, if a Safari user drags a HTML file over an element with a dragzone attribute set to file:text/plain, the polyfill will decide that the dragged file matches the dragzone conditions. However, the polyfill will not match non-file drags to the dragzone value above.

On the other hand, it is worth noting that dropzone / webkitdropzone were never implemented in Firefox so, if your application relies on these attributes, it is already broken in Firefox. Along the same lines, the webkitdropzone in Chrome was unable to match file: tokens against dragged files, until M57.

In conclusion, if you wish to accept file drags in a portable manner, you need to use the imperative API for handling drops.

dropzone-polyfill's People

Contributors

pwnall avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.