@sensorskit/vue-on-delete
Advanced tools
Comparing version 1.0.3 to 1.1.0
@@ -0,0 +0,0 @@ module.exports = { |
@@ -0,0 +0,0 @@ import Vue from 'vue' |
@@ -1,1 +0,1 @@ | ||
!function(e,n){"object"==typeof exports&&"object"==typeof module?module.exports=n():"function"==typeof define&&define.amd?define([],n):"object"==typeof exports?exports.VueOnDelete=n():e.VueOnDelete=n()}(window,function(){return function(e){var n={};function t(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,t),o.l=!0,o.exports}return t.m=e,t.c=n,t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},t.r=function(e){Object.defineProperty(e,"__esModule",{value:!0})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},t.p="/lib/",t(t.s=0)}([function(e,n,t){"use strict";t.r(n);var r=function(e,n){var t=e.split(""),r=n.split(""),o=null,u=null;if(e===n||e.length<n.length)return!1;if(e.indexOf(n)>=0)return!0;for(var i=0;i<r.length;i++)if(r[i]!==t[i]){o=i;break}for(var l=1;l<=r.length;l++)if(r[r.length-l]!==t[t.length-l]){u=r.length-l;break}return u-o<0},o=function(e){return u(e)?e:"DIV"===e.tagName&&e.querySelector("input")?e.querySelector("input"):null},u=function(e){return"INPUT"===e.tagName};var i={},l=[],f=function(){for(var e,n=arguments.length,t=Array(n),r=0;r<n;r++)t[r]=arguments[r];(e=console).error.apply(e,["[vue-on-delete]"].concat(function(e){if(Array.isArray(e)){for(var n=0,t=Array(e.length);n<e.length;n++)t[n]=e[n];return t}return Array.from(e)}(t)))},c=function(e,n,t){return e.addEventListener(n,t,!1),{el:e,destroy:function(){return e.removeEventListener(n,t,!1)}}},a=function(e,n,t){if(!(e=o(e)))return f("绑定的元素内未找到 input 标签!");var u=n.value;if("function"==typeof u){p(e);var i=e.value,a=null,s=!1;l.push(c(e,"focus",function(){i=e.value}),c(e,"input",function(){s||(a=e.value,r(i,a)&&u(),i=a)}),c(e,"compositionstart",function(){s=!0}),c(e,"compositionend",function(){s=!1}))}else f("指令需要传入一个函数!")},p=function(e){if(e=o(e),l.length)for(var n=l.length-1;n>=0;){var t=l[n];t.el===e&&(t.destroy(),l.splice(n,1)),n-=1}},s=function(e,n){n.value!==n.oldValue&&a(e,n)};i.install=function(e,n){var t=n&&n.directive?n.directive:"on-delete";e.directive(t,{bind:a,update:s,unbind:p})};n.default=i}])}); | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.VueOnDelete=t():e.VueOnDelete=t()}(window,function(){return function(e){var t={};function n(o){if(t[o])return t[o].exports;var r=t[o]={i:o,l:!1,exports:{}};return e[o].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=e,n.c=t,n.d=function(e,t,o){n.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:o})},n.r=function(e){Object.defineProperty(e,"__esModule",{value:!0})},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="/lib/",n(n.s=0)}([function(e,t,n){"use strict";n.r(t);var o=function(e,t){var n=e.split(""),o=t.split(""),r=null,u=null;if(e===t||e.length<t.length)return!1;if(e.indexOf(t)>=0)return!0;for(var i=0;i<o.length;i++)if(o[i]!==n[i]){r=i;break}for(var l=1;l<=o.length;l++)if(o[o.length-l]!==n[n.length-l]){u=o.length-l;break}return u-r<0},r=function(e){return u(e)?e:"DIV"===e.tagName&&e.querySelector("input")?e.querySelector("input"):null},u=function(e){return"INPUT"===e.tagName},i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};var l={},f=[],c=function(){for(var e,t=arguments.length,n=Array(t),o=0;o<t;o++)n[o]=arguments[o];(e=console).error.apply(e,["[vue-on-delete]"].concat(function(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t<e.length;t++)n[t]=e[t];return n}return Array.from(e)}(n)))},a=function(e,t,n){return e.addEventListener(t,n,!1),{el:e,destroy:function(){return e.removeEventListener(t,n,!1)}}},d=function(e,t,n){if(!(e=r(e)))return c("绑定的元素内未找到 input 标签!");var u=t.value;if("object"===(void 0===u?"undefined":i(u))||"function"==typeof u)if("object"!==(void 0===u?"undefined":i(u))||"function"==typeof u.method){p(e);var l=e.value,d=null,v=!1;f.push(a(e,"focus",function(){l=e.value}),a(e,"input",function(){if(!v){if(d=e.value,o(l,d))if("object"===(void 0===u?"undefined":i(u))){u.method;var t=function(e,t){var n={};for(var o in e)t.indexOf(o)>=0||Object.prototype.hasOwnProperty.call(e,o)&&(n[o]=e[o]);return n}(u,["method"]);0===Object.keys(t).length?u.method():u.method(t)}else u();l=d}}),a(e,"compositionstart",function(){v=!0}),a(e,"compositionend",function(){v=!1}))}else c("指令对象必须包含method且method必须为函数!");else c("指令需要传入一个函数或对象!")},p=function(e){if(e=r(e),f.length)for(var t=f.length-1;t>=0;){var n=f[t];n.el===e&&(n.destroy(),f.splice(t,1)),t-=1}},v=function(e,t){t.value!==t.oldValue&&("function"==typeof t.value&&"object"===i(t.oldValue)&&t.value===t.oldValue.method||"function"==typeof t.oldValue&&"object"===i(t.value)&&t.oldValue===t.value.method||"object"===i(t.oldValue)&&"object"===i(t.value)&&t.value.method===t.oldValue.method||d(e,t))};l.install=function(e,t){var n=t&&t.directive?t.directive:"on-delete";e.directive(n,{bind:d,update:v,unbind:p})};t.default=l}])}); |
{ | ||
"name": "@sensorskit/vue-on-delete", | ||
"description": "vue custom directive of delete binding", | ||
"version": "1.0.3", | ||
"version": "1.1.0", | ||
"author": "newraina <newraina@users.noreply.github.com>", | ||
@@ -6,0 +6,0 @@ "main": "lib/vue-on-delete.js", |
@@ -0,0 +0,0 @@ # vue-on-delete |
@@ -0,1 +1,2 @@ | ||
/* eslint-disable no-useless-return */ | ||
import isDelete from './isDelete' | ||
@@ -28,6 +29,11 @@ import { getInputFromEl } from './util' | ||
const onDelete = binding.value | ||
if (typeof onDelete !== 'function') { | ||
log.e('指令需要传入一个函数!') | ||
if (typeof onDelete !== 'object' && typeof onDelete !== 'function') { | ||
log.e('指令需要传入一个函数或对象!') | ||
return | ||
} else if ( | ||
typeof onDelete === 'object' && | ||
typeof onDelete.method !== 'function' | ||
) { | ||
log.e('指令对象必须包含method且method必须为函数!') | ||
return | ||
} | ||
@@ -58,3 +64,13 @@ | ||
if (isDelete(strOld, strNew)) { | ||
onDelete() | ||
if (typeof onDelete === 'object') { | ||
let { method, ...args } = onDelete | ||
if (Object.keys(args).length === 0) { | ||
onDelete.method() | ||
} else { | ||
onDelete.method(args) | ||
} | ||
} else { | ||
onDelete() | ||
} | ||
} | ||
@@ -103,2 +119,20 @@ strOld = strNew | ||
return | ||
} else if ( | ||
typeof binding.value === 'function' && | ||
typeof binding.oldValue === 'object' && | ||
binding.value === binding.oldValue.method | ||
) { | ||
return | ||
} else if ( | ||
typeof binding.oldValue === 'function' && | ||
typeof binding.value === 'object' && | ||
binding.oldValue === binding.value.method | ||
) { | ||
return | ||
} else if ( | ||
typeof binding.oldValue === 'object' && | ||
typeof binding.value === 'object' && | ||
binding.value.method === binding.oldValue.method | ||
) { | ||
return | ||
} | ||
@@ -105,0 +139,0 @@ bind(el, binding) |
@@ -0,0 +0,0 @@ const isDelete = (strOld, strNew) => { |
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ import { mount, createLocalVue } from '@vue/test-utils' |
@@ -0,0 +0,0 @@ global.Range = function Range() {} |
@@ -0,0 +0,0 @@ const path = require('path') |
@@ -0,0 +0,0 @@ const path = require('path') |
@@ -0,0 +0,0 @@ const path = require('path') |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
339698
471
1