Skip to content

Commit

Permalink
Merge pull request #20 from piboistudios/master
Browse files Browse the repository at this point in the history
Add Internet Explorer polyfills
  • Loading branch information
nikolasp authored Jan 25, 2019
2 parents 927cc0f + 14a846a commit a3ae687
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 0 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,15 @@ Vue.use(VueDraggable)

Included TypeScript definitions.

## Browser Compatibility
Polyfills for IE9+ support are included in the repo.

If you need to support IE9 in your applications, import the polyfills folder:

```javascript
import 'vue-draggable/polyfills'
```

## Usage

In the template, use the `v-drag-and-drop` directive:
Expand Down
39 changes: 39 additions & 0 deletions polyfills/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
IE polyfills
closest: https://developer.mozilla.org/en-US/docs/Web/API/Element/closest
remove: https://developer.mozilla.org/en-US/docs/Web/API/ChildNode/remove
*/
if (!Element.prototype.matches) {
Element.prototype.matches = Element.prototype.msMatchesSelector ||
Element.prototype.webkitMatchesSelector;
}

if (!Element.prototype.closest) {
Element.prototype.closest = function (s) {
var el = this;

do {
if (el.matches(s)) return el;
el = el.parentElement || el.parentNode;
} while (el !== null && el.nodeType === 1);
return null;
};
}
// from:https://github.com/jserz/js_piece/blob/master/DOM/ChildNode/remove()/remove().md
(function (arr) {
arr.forEach(function (item) {
if (item.hasOwnProperty('remove')) {
return;
}
Object.defineProperty(item, 'remove', {
configurable: true,
enumerable: true,
writable: true,
value: function remove() {
if (this.parentNode !== null)
this.parentNode.removeChild(this);
}
});
});
})([Element.prototype, CharacterData.prototype, DocumentType.prototype]);

1 change: 1 addition & 0 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { VueDraggable } from './core';


export const VueDraggableDirective = {
bind(el, options) {
// override default options
Expand Down

0 comments on commit a3ae687

Please sign in to comment.