Comparing version 1.0.3 to 1.1.0
@@ -5,2 +5,3 @@ var namespace = require('can-namespace'); | ||
* @parent can-infrastructure | ||
* @package ./package.json | ||
* @signature `cid(object, optionalObjectType)` | ||
@@ -29,9 +30,18 @@ * | ||
var _cid = 0; | ||
// DOM nodes shouldn't all use the same property | ||
var domExpando = "can" + new Date(); | ||
var cid = function (object, name) { | ||
if (!object._cid) { | ||
var propertyName = object.nodeName ? domExpando : "_cid"; | ||
if (!object[propertyName]) { | ||
_cid++; | ||
object._cid = (name || '') + _cid; | ||
object[propertyName] = (name || '') + _cid; | ||
} | ||
return object._cid; | ||
return object[propertyName]; | ||
}; | ||
cid.domExpando = domExpando; | ||
cid.get = function(object){ | ||
var propertyName = object.nodeName ? domExpando : "_cid"; | ||
return object[propertyName]; | ||
}; | ||
@@ -38,0 +48,0 @@ if (namespace.cid) { |
{ | ||
"name": "can-cid", | ||
"version": "1.0.3", | ||
"version": "1.1.0", | ||
"description": "Utility for getting a unique identifier for an object", | ||
@@ -19,3 +19,3 @@ "homepage": "http://canjs.com", | ||
"postversion": "git push --tags && git checkout master && git branch -D release && git push", | ||
"testee": "testee test/test.html --browsers firefox", | ||
"testee": "testee test.html --browsers firefox", | ||
"test": "npm run jshint && npm run testee", | ||
@@ -27,3 +27,2 @@ "jshint": "jshint ./*.js --config", | ||
"build": "node build.js", | ||
"document": "documentjs", | ||
"develop": "done-serve --static --develop --port 8080" | ||
@@ -45,3 +44,3 @@ }, | ||
"donejs-cli": "^0.9.4", | ||
"generator-donejs": "^0.9.0", | ||
"generator-donejs": "^1.0.7", | ||
"jshint": "^2.9.1", | ||
@@ -48,0 +47,0 @@ "steal": "^1.2.8", |
# can-cid | ||
[![Build Status](https://travis-ci.org/canjs/can-cid.png?branch=master)](https://travis-ci.org/canjs/can-cid) | ||
[![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-cid/blob/master/LICENSE.md) | ||
[![npm version](https://badge.fury.io/js/can-cid.svg)](https://www.npmjs.com/package/can-cid) | ||
[![Travis build status](https://travis-ci.org/canjs/can-cid.svg?branch=master)](https://travis-ci.org/canjs/can-cid) | ||
[![Greenkeeper badge](https://badges.greenkeeper.io/canjs/can-cid.svg)](https://greenkeeper.io/) | ||
Utility for getting a unique identifier for an object | ||
## Usage | ||
## Documentation | ||
### ES6 use | ||
Read the [can-cid API docs on CanJS.com](https://canjs.com/doc/can-cid.html). | ||
With StealJS, you can import this module directly in a template that is autorendered: | ||
## Changelog | ||
```js | ||
import plugin from 'can-cid'; | ||
``` | ||
See the [latest releases on GitHub](https://github.com/canjs/can-cid/releases). | ||
### CommonJS use | ||
Use `require` to load `can-cid` and everything else | ||
needed to create a template that uses `can-cid`: | ||
```js | ||
var plugin = require("can-cid"); | ||
``` | ||
## AMD use | ||
Configure the `can` and `jquery` paths and the `can-cid` package: | ||
```html | ||
<script src="require.js"></script> | ||
<script> | ||
require.config({ | ||
paths: { | ||
"jquery": "node_modules/jquery/dist/jquery", | ||
"can": "node_modules/canjs/dist/amd/can" | ||
}, | ||
packages: [{ | ||
name: 'can-cid', | ||
location: 'node_modules/can-cid/dist/amd', | ||
main: 'lib/can-cid' | ||
}] | ||
}); | ||
require(["main-amd"], function(){}); | ||
</script> | ||
``` | ||
### Standalone use | ||
Load the `global` version of the plugin: | ||
```html | ||
<script src='./node_modules/can-cid/dist/global/can-cid.js'></script> | ||
``` | ||
## Contributing | ||
### Making a Build | ||
The [contribution guide](https://github.com/canjs/can-cid/blob/master/CONTRIBUTING.md) has information on getting help, reporting bugs, developing locally, and more. | ||
To make a build of the distributables into `dist/` in the cloned repository run | ||
## License | ||
``` | ||
npm install | ||
node build | ||
``` | ||
[MIT](https://github.com/canjs/can-cid/blob/master/LICENSE.md) | ||
### Running the tests | ||
Tests can run in the browser by opening a webserver and visiting the `test.html` page. | ||
Automated tests that run the tests from the command line in Firefox can be run with | ||
``` | ||
npm test | ||
``` |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
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
No License Found
License(Experimental) License information could not be found.
Found 1 instance in 1 package
17042
20
0
284
27
2