Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@sensorskit/vue-on-delete

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sensorskit/vue-on-delete - npm Package Compare versions

Comparing version 1.0.2 to 1.0.3

src/util.js

2

lib/vue-on-delete.js

@@ -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};var o={},u=[],i=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)))},l=function(e,n,t){return e.addEventListener(n,t,!1),{el:e,destroy:function(){return e.removeEventListener(n,t,!1)}}},f=function(e,n,t){if("function"==typeof n.value){c(e);var o=e.value,f=null,a=!1;u.push(l(e,"focus",function(){o=e.value}),l(e,"input",function(){a||(f=e.value,r(o,f)&&n.value(),o=f)}),l(e,"compositionstart",function(){a=!0}),l(e,"compositionend",function(){a=!1}))}else i("指令需要传入一个函数!")},c=function(e){if(u.length)for(var n=u.length-1;n>=0;){var t=u[n];t.el===e&&(t.destroy(),u.splice(n,1)),n-=1}},a=function(e,n){n.value!==n.oldValue&&f(e,n)};o.install=function(e,n){var t=n&&n.directive?n.directive:"on-delete";e.directive(t,{bind:f,update:a,unbind:c})};n.default=o}])});
!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}])});
{
"name": "@sensorskit/vue-on-delete",
"description": "vue custom directive of delete binding",
"version": "1.0.2",
"version": "1.0.3",
"author": "newraina <newraina@users.noreply.github.com>",

@@ -6,0 +6,0 @@ "main": "lib/vue-on-delete.js",

# vue-on-delete
[![npm (scoped)](https://img.shields.io/npm/v/@sensorskit/vue-on-delete.svg)](https://www.npmjs.com/package/@sensorskit/vue-on-delete)
[![Build Status](https://travis-ci.org/SensorsKit/vue-on-delete.svg?branch=master)](https://travis-ci.org/SensorsKit/vue-on-delete)
[![Build Status](https://travis-ci.org/SensorsKit/vue-on-delete.svg?branch=master)](https://travis-ci.org/SensorsKit/vue-on-delete)

@@ -11,10 +11,11 @@ [[在线预览]](https://sensorskit.github.io/vue-on-delete/)

> 示例:
> - 输入框里有字符存在时,按下了退格键,算删除
> - 输入框里没有字符,按下退格键,不算删除
> - 输入框里选中了一段文字,按下退格键,算删除
> - 输入框里选中了一段文字,键入别的字符,此时选中文字会被替换掉,不算删除
>
> * 输入框里有字符存在时,按下了退格键,算删除
> * 输入框里没有字符,按下退格键,不算删除
> * 输入框里选中了一段文字,按下退格键,算删除
> * 输入框里选中了一段文字,键入别的字符,此时选中文字会被替换掉,不算删除
## 使用
``` bash
```bash
yarn add @sensorskit/vue-on-delete

@@ -32,3 +33,3 @@ ```

Vue.use(VueOnDelete, {
directive: 'your-custom-directive-name'
directive: 'your-custom-directive-name'
})

@@ -35,0 +36,0 @@ ```

import isDelete from './isDelete'
import { getInputFromEl } from './util'

@@ -20,2 +21,8 @@ const OnDeletePlugin = {}

const bind = (el, binding, vnode) => {
el = getInputFromEl(el)
if (!el) {
return log.e('绑定的元素内未找到 input 标签!')
}
const onDelete = binding.value

@@ -51,3 +58,3 @@

if (isDelete(strOld, strNew)) {
binding.value()
onDelete()
}

@@ -73,2 +80,4 @@ strOld = strNew

const unbind = el => {
el = getInputFromEl(el)
if (!registeredHandlers.length) {

@@ -75,0 +84,0 @@ return

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc