├── .gitignore ├── .jshintrc ├── LICENCE ├── README.md ├── index.js ├── package.json └── test.js /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .monitor 3 | .*.swp 4 | .nodemonignore 5 | releases 6 | *.log 7 | *.err 8 | fleet.json 9 | public/browserify 10 | bin/*.json 11 | .bin 12 | build 13 | compile 14 | .lock-wscript 15 | node_modules 16 | 17 | -------------------------------------------------------------------------------- /.jshintrc: -------------------------------------------------------------------------------- 1 | { 2 | "maxdepth": 4, 3 | "maxstatements": 200, 4 | "maxcomplexity": 12, 5 | "maxlen": 80, 6 | "maxparams": 5, 7 | 8 | "curly": true, 9 | "eqeqeq": true, 10 | "immed": true, 11 | "latedef": false, 12 | "noarg": true, 13 | "noempty": true, 14 | "nonew": true, 15 | "undef": true, 16 | "unused": "vars", 17 | "trailing": true, 18 | 19 | "quotmark": true, 20 | "expr": true, 21 | "asi": true, 22 | 23 | "browser": false, 24 | "esnext": true, 25 | "devel": false, 26 | "node": false, 27 | "nonstandard": false, 28 | 29 | "predef": ["require", "module", "__dirname", "__filename"] 30 | } 31 | -------------------------------------------------------------------------------- /LICENCE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012 Colingo. 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ev-store 2 | 3 | Stores event listeners and event handles on a DOM object 4 | 5 | ## Example 6 | 7 | ```js 8 | var EvStore = require('ev-store'); 9 | 10 | var elem = someElement 11 | var events = EvStore(elem) 12 | 13 | events.click = function () { 14 | /* ... */ 15 | }; 16 | ``` 17 | 18 | ## Installation 19 | 20 | `npm install ev-store` 21 | 22 | ## Contributors 23 | 24 | - Raynos 25 | 26 | ## MIT Licenced 27 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var OneVersionConstraint = require('individual/one-version'); 4 | 5 | var MY_VERSION = '7'; 6 | OneVersionConstraint('ev-store', MY_VERSION); 7 | 8 | var hashKey = '__EV_STORE_KEY@' + MY_VERSION; 9 | 10 | module.exports = EvStore; 11 | 12 | function EvStore(elem) { 13 | var hash = elem[hashKey]; 14 | 15 | if (!hash) { 16 | hash = elem[hashKey] = {}; 17 | } 18 | 19 | return hash; 20 | } 21 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ev-store", 3 | "version": "7.0.0", 4 | "description": "Stores event listeners and event handles on a DOM object", 5 | "keywords": [], 6 | "author": "Raynos ", 7 | "repository": "git://github.com/Raynos/ev-store.git", 8 | "main": "index", 9 | "homepage": "https://github.com/Raynos/ev-store", 10 | "contributors": [ 11 | { 12 | "name": "Raynos" 13 | } 14 | ], 15 | "bugs": { 16 | "url": "https://github.com/Raynos/ev-store/issues", 17 | "email": "raynos2@gmail.com" 18 | }, 19 | "dependencies": { 20 | "individual": "^3.0.0" 21 | }, 22 | "devDependencies": { 23 | "element": "~0.1.4", 24 | "global": "^4.3.0", 25 | "individual": "^3.0.0", 26 | "min-document": "^2.12.0", 27 | "run-browser": "^1.3.1", 28 | "tap-spec": "^0.1.9", 29 | "tape": "~2.12.0" 30 | }, 31 | "licenses": [ 32 | { 33 | "type": "MIT", 34 | "url": "http://github.com/Raynos/ev-store/raw/master/LICENSE" 35 | } 36 | ], 37 | "scripts": { 38 | "test": "run-browser test.js -b | tap-spec" 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /test.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var EvStore = require('./index.js'); 4 | 5 | var test = require('tape'); 6 | var document = require('global/document'); 7 | 8 | test('can fetch records out of DS', function t(assert) { 9 | var elem = document.body; 10 | var ds = EvStore(elem); 11 | 12 | ds.foo = 'bar'; 13 | 14 | var ds2 = EvStore(elem); 15 | 16 | assert.equal(ds2.foo, 'bar'); 17 | 18 | assert.end(); 19 | }); 20 | 21 | test('setting dash names', function t(assert) { 22 | var elem = document.createElement('div'); 23 | EvStore(elem)['foo-bar'] = 'baz'; 24 | 25 | var ds = EvStore(elem); 26 | 27 | assert.equal(ds['foo-bar'], 'baz'); 28 | 29 | assert.end(); 30 | }); 31 | --------------------------------------------------------------------------------