Skip to content

Commit

Permalink
Fix bad merge.
Browse files Browse the repository at this point in the history
  • Loading branch information
Romick2005 committed Sep 18, 2018
1 parent b3f5499 commit 2003311
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vue-draggable-resizable",
"version": "2.0.0-beta.0",
"version": "2.0.1",
"author": "Maurizio Bonani <maurizio.bonani@gmail.com>",
"main": "dist/index.js",
"jsnext:main": "src/index.js",
Expand Down
57 changes: 57 additions & 0 deletions src/utils/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
export function isFunction(func) {
return typeof func === "function" || Object.prototype.toString.call(func) === "[object Function]";
}

export function matchesSelectorToParentElements(el, selector, baseNode) {
let node = el;

const matchesSelectorFunc = [
"matches",
"webkitMatchesSelector",
"mozMatchesSelector",
"msMatchesSelector",
"oMatchesSelector"
].find(func => isFunction(node[func]));

if (!isFunction(node[matchesSelectorFunc])) {
return false;
}

do {
if (node[matchesSelectorFunc](selector)) {
return true;
}
if (node === baseNode) {
return false;
}
node = node.parentNode;
} while (node);

return false;
}

export function addEvent(el, event, handler) {
if (!el) {
return false;
}
if (el.attachEvent) {
el.attachEvent("on" + event, handler);
} else if (el.addEventListener) {
el.addEventListener(event, handler, true);
} else {
el["on" + event] = handler;
}
}

export function removeEvent(el, event, handler) {
if (!el) {
return false;
}
if (el.detachEvent) {
el.detachEvent("on" + event, handler);
} else if (el.removeEventListener) {
el.removeEventListener(event, handler, true);
} else {
el["on" + event] = null;
}
}

0 comments on commit 2003311

Please sign in to comment.