New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

can-event-dom-radiochange

Package Overview
Dependencies
Maintainers
5
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

can-event-dom-radiochange - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

31

can-event-dom-radiochange-test.js

@@ -5,3 +5,2 @@ 'use strict';

var domEvents = require('can-dom-events');
var oldEvents = require('can-util/dom/events/events');
var definition = require('./can-event-dom-radiochange');

@@ -14,20 +13,2 @@ var compat = require('./compat');

// Fix oldEvent calls to match new syntax
function newifyOldEvents (oldEvents) {
return {
addEventListener: function (target) {
var args = Array.prototype.slice.call(arguments, 1);
return oldEvents.addEventListener.apply(target, args);
},
removeEventListener: function (target) {
var args = Array.prototype.slice.call(arguments, 1);
return oldEvents.removeEventListener.apply(target, args);
},
dispatch: function (target) {
var args = Array.prototype.slice.call(arguments, 1);
return oldEvents.dispatch.apply(target, args);
},
};
}
var compatWithNew = {

@@ -44,13 +25,2 @@ name: 'compat with can-dom-events',

var compatWithOld = {
name: 'compat with can-util/dom/events',
domEvents: newifyOldEvents(oldEvents),
setup: function () {
this.removeEvent = compat(oldEvents);
},
teardown: function () {
this.removeEvent();
}
};
var rawNewDomEvents = {

@@ -68,3 +38,2 @@ name: 'plain with can-dom-events',

var suites = [
compatWithOld,
compatWithNew,

@@ -71,0 +40,0 @@ rawNewDomEvents

46

can-event-dom-radiochange.js
'use strict';
var events = require('can-util/dom/events/events');
var domData = require('can-util/dom/data/data');
var getDocument = require('can-util/dom/document/document');
var domData = require('can-dom-data-state');
var getDocument = require('can-globals/document/document');
var domEvents = require('can-dom-events');
var CIDMap = require('can-util/js/cid-map/cid-map');
var CIDMap = require('can-cid/map/map');

@@ -65,3 +64,3 @@ function getRoot (el) {

function attachRootListener (root, eventName) {
function attachRootListener (root, eventName, events) {
var listenerName = getListenerName(eventName);

@@ -78,7 +77,7 @@ var listener = domData.get.call(root, listenerName);

};
events.addEventListener.call(root, 'change', newListener);
events.addEventListener(root, 'change', newListener);
domData.set.call(root, listenerName, newListener);
}
function detachRootListener (root, eventName) {
function detachRootListener (root, eventName, events) {
var listenerName = getListenerName(eventName);

@@ -93,7 +92,7 @@ var listener = domData.get.call(root, listenerName);

}
events.removeEventListener.call(root, 'change', listener);
events.removeEventListener(root, 'change', listener);
domData.clean.call(root, listenerName);
}
function addListener (eventName, el) {
function addListener (eventName, el, events) {
if (!isRadioInput(el)) {

@@ -104,9 +103,9 @@ throw new Error('Listeners for ' + eventName + ' must be radio inputs');

getRegistry(root, eventName).set(el, el);
attachRootListener(root, eventName);
attachRootListener(root, eventName, events);
}
function removeListener (eventName, el) {
function removeListener (eventName, el, events) {
var root = getRoot(el);
getRegistry(root, eventName).delete(el);
detachRootListener(root, eventName);
detachRootListener(root, eventName, events);
}

@@ -117,2 +116,3 @@

* @parent can-infrastructure
* @package ./package.json
*

@@ -127,16 +127,14 @@ * A custom event for listening to changes of inputs with type "radio",

* ```js
* var events = require("can-util/dom/events/events");
* var radioChange = require("can-util/dom/events/radiochange/radiochange");
* events.addCustomEvent(radioChange);
* var domEvents = require('can-dom-events');
* var radioChange = require('can-event-dom-radiochange');
* domEvents.addEvent(radioChange);
*
* var el = document.createElement("div");
* var target = document.createElement('input');
*
* function radiochangeHandler() {
* console.log("radiochange event fired");
* function handler () {
* console.log('radiochange event fired');
* }
*
* events.addEventListener.call(el, "radiochange", radiochangeHandler, false);
* events.removeEventListener.call(el, "radiochange", radiochangeHandler);
*
* events.removeCustomEvent(radioChange);
* domEvents.addEventListener(target, 'radiochange', handler);
* domEvents.removeEventListener(target, 'radiochange', handler);
* ```

@@ -148,3 +146,3 @@ */

addEventListener: function (target, eventName, handler) {
addListener(eventName, target);
addListener(eventName, target, this);
target.addEventListener(eventName, handler);

@@ -154,5 +152,5 @@ },

removeEventListener: function (target, eventName, handler) {
removeListener(eventName, target);
removeListener(eventName, target, this);
target.removeEventListener(eventName, handler);
}
};
{
"name": "can-event-dom-radiochange",
"description": "Custom radiochange event",
"version": "1.0.0",
"version": "1.0.1",
"author": {

@@ -14,4 +14,6 @@ "name": "Chris Andrejewski",

"dependencies": {
"can-cid": "^1.1.0",
"can-dom-data-state": "^0.1.1",
"can-dom-events": "^1.0.2",
"can-util": "^3.8.4"
"can-globals": "^0.1.0"
},

@@ -18,0 +20,0 @@ "devDependencies": {

# can-event-dom-radiochange
[![Build Status](https://travis-ci.org/canjs/can-event-dom-radiochange.svg?branch=master)](https://travis-ci.org/canjs/can-event-dom-radiochange)
[![Join the chat at https://gitter.im/canjs/canjs](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/canjs/canjs?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://github.com/canjs/can-event-dom-radiochange/blob/master/LICENSE)
[![npm version](https://badge.fury.io/js/can-event-dom-radiochange.svg)](https://www.npmjs.com/package/can-event-dom-radiochange)
[![Travis build status](https://travis-ci.org/canjs/can-event-dom-radiochange.svg?branch=master)](https://travis-ci.org/canjs/can-event-dom-radiochange)
[![AppVeyor build status](https://ci.appveyor.com/api/projects/status/github/canjs/can-event-dom-radiochange?branch=master&svg=true)](https://ci.appveyor.com/project/matthewp/can-event-dom-radiochange)
[![Coverage status](https://coveralls.io/repos/github/canjs/can-event-dom-radiochange/badge.svg?branch=master)](https://coveralls.io/github/canjs/can-event-dom-radiochange?branch=master)
[![Greenkeeper badge](https://badges.greenkeeper.io/canjs/can-event-dom-radiochange.svg)](https://greenkeeper.io/)
A custom event for listening to changes of inputs with type "radio", which fires when a conflicting radio input changes. A "conflicting" radio button has the same "name" attribute and exists within in the same form, or lack thereof. This event coordinates state bound to whether a radio is checked. The "change" event does not fire for deselected radios. By using this event instead, deselected radios receive notification.
## Usage
## Documentation
### ES6 use
Read the [can-event-dom-radiochange API docs on CanJS.com](https://canjs.com/doc/can-event-dom-radiochange.html).
With StealJS, you can import this module directly in an auto-rendered template:
## Changelog
```js
import radioChange from 'can-event-dom-radiochange';
import domEvents from 'can-util/dom/events';
domEvents.addCustomEvent(radioChange);
```
See the [latest releases on GitHub](https://github.com/canjs/can-event-dom-radiochange/releases).
### CommonJS use
## Contributing
Use `require` to load `can-event-dom-radiochange` and everything else
needed to create a template that uses `can-event-dom-radiochange`:
The [contribution guide](https://github.com/canjs/can-event-dom-radiochange/blob/master/CONTRIBUTING.md) has information on getting help, reporting bugs, developing locally, and more.
```js
var radioChange = require("can-event-dom-radiochange");
var domEvents = require('can-util/dom/events');
domEvents.addCustomEvent(radioChange);
```
## License
### Standalone use
[MIT](https://github.com/canjs/can-event-dom-radiochange/blob/master/LICENSE)
Load the `global` version of the plugin:
```html
<script src='./node_modules/can-event-dom-radiochange/dist/global/can-event-dom-radiochange.js'></script>
```
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