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

bazooka

Package Overview
Dependencies
Maintainers
2
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bazooka - npm Package Compare versions

Comparing version 0.7.0 to 0.8.0

docs/helpers.md

19

CHANGELOG.md

@@ -0,1 +1,17 @@

## 0.8.0
* :x: [removed] `Baz.h.getAttrs(node)`. Use `Baz.h.getAttrs(prefix, node)` or `Baz.h.getAttrs(prefix)(node)` instead _(deprecated since 0.4.1)_
* :wrench: [fixed] parsing pretty/multiline JSON (like `{\n"a": 1\n}`) by `Baz.h.getAttrs`:
```javascript
// node = <div data-baz-json='{\n"a": 1\n}' />
Baz.h.getAttrs('baz', node).json
// prior 0.8.0
// => '{\n"a": 1\n}'
// after 0.8.0
// => { "a": 1 }
```
## 0.7.0

@@ -23,4 +39,3 @@

* :warning: [deprecated] `Baz.h.getAttrs(node)`. Use `Baz.h.getAttrs(prefix, node)` or `Baz.h.getAttrs(prefix)(node)`
instead
* :warning: [deprecated] `Baz.h.getAttrs(node)`. Use `Baz.h.getAttrs(prefix, node)` or `Baz.h.getAttrs(prefix)(node)` instead

@@ -27,0 +42,0 @@ ## 0.4.0

6

docs/hot-reloadable-bazfuncs.md

@@ -15,3 +15,3 @@ # Hot reloadable `bazFunc`s

+ return () => {
+ node.removeEventListener('click', boundHandler);
+ node.removeEventListener('click', clickHandler);
+ };

@@ -34,6 +34,6 @@ };

const boundHandler = clickHandler(node, state);
node.addEventListener('click', boundHandler);
node.addEventListener('click', clickHandler);
return () => {
node.removeEventListener('click', boundHandler);
node.removeEventListener('click', clickHandler);
};

@@ -40,0 +40,0 @@ }

@@ -36,3 +36,3 @@ ## Modules

**Kind**: inner interface of <code>[BazComponent](#module_BazComponent)</code>
**Returns**: <code>function</code> - `dispose` callback to cleanup components `eventListeners`, timers, etc. after [Bazooka.rebind](#module_Bazooka.rebind) or removal of the node from DOM
**Returns**: <code>function</code> - `dispose` callback to cleanup component's `eventListeners`, timers, etc. after [Bazooka.rebind](#module_Bazooka.rebind) or removal of the node from DOM

@@ -39,0 +39,0 @@ | Type | Description |

{
"name": "bazooka",
"version": "0.7.0",
"version": "0.8.0",
"description": "Simple tool for declarative binding applications to HTML nodes.",

@@ -17,3 +17,3 @@ "main": "src/main.js",

"postversion": "git push && git push --tags",
"docs": "mkdir -p ./docs && jsdoc2md src/main.js > ./docs/README.md",
"docs": "mkdir -p ./docs && jsdoc2md src/main.js > ./docs/README.md && jsdoc2md src/helpers.js > ./docs/helpers.md",
"examples": "webpack --config=webpack.config.examples.js"

@@ -45,10 +45,9 @@ },

"jsdoc-to-markdown": "^1.2.0",
"karma": "^0.13.15",
"karma": "1.0.0",
"karma-jasmine": "^0.3.6",
"karma-phantomjs-launcher": "^0.2.1",
"karma-phantomjs-shim": "^1.2.0",
"karma-phantomjs-launcher": "1.0.4",
"karma-webpack": "^1.7.0",
"kefir": "^3.1.0",
"lodash": "^3.10.1",
"phantomjs": "^1.9.18",
"phantomjs-prebuilt": "2.1.7",
"prettier": "^0.22.0",

@@ -55,0 +54,0 @@ "react": "^0.14.2",

@@ -39,2 +39,3 @@ # bazooka [![Build Status](https://travis-ci.org/seedofjoy/bazooka.svg)](https://travis-ci.org/seedofjoy/bazooka)

- [API](docs/README.md)
- [Helpers (`Baz.h`)](docs/helpers.md)
- [Hot Reloadable `bazFunc`s](docs/hot-reloadable-bazfuncs.md)

@@ -41,0 +42,0 @@

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

var rbrace = /^(?:\{.*\}|\[.*\])$/;
// `[\s\S]` instead of `.` to allow multiline/pretty JSON
// in other words, because `/./.test('\n') == false`
var rbrace = /^(?:\{[\s\S]*\}|\[[\s\S]*\])$/;
var rdataAttr = /^data-([a-z\d\-]+)$/;

@@ -74,7 +76,26 @@ var rdashAlpha = /-([a-z])/gi;

/**
* @param {string} [prefix] - data-attribute prefix
* @param {HTMLNode} node - target node
* @module h
* @memberof Bazooka
*/
var h = {};
/**
* Get all prefixed `data-` attributes as an object
* @func getAttrs
* @static
* @param {string} prefix - `data-`attribute prefix
* @param {HTMLNode} [node] - target node
* @returns {function|object} - curried function for parsing node with passed prefix or parsed attrs
* @example
* ```javascript
* // <div id="n" data-x-a="lol" data-x-b="1" data-y-c='{"key": 1}' data-y-composed-attr="true"></div>
*
* Baz.h.getAttrs('x', window.n) // => {a: "lol", b: 1}
* Baz.h.getAttrs('y', window.n) // => {y: {key: 1}, composedAttr: true}
*
* const xAttrs = Baz.h.getAttrs('x')
* xAttrs(window.n) // => {x: "lol", b: 1}
* ```
*/
var getAttrs = function(prefix, node) {
h.getAttrs = function(prefix, node) {
if (typeof prefix === 'string' && node === void 0) {

@@ -84,12 +105,2 @@ return _getPrefixedAttrs.bind(null, prefix);

if (node === void 0) {
if (process.env.NODE_ENV != 'production') {
console.warn(
'`Baz.h.getAttrs(node)` is deprecated. Use `Baz.h.getAttrs(prefix, node)` or `Baz.h.getAttrs(prefix)(node)` instead'
);
}
node = prefix;
return _getPrefixedAttrs('', node);
}
return _getPrefixedAttrs(prefix, node);

@@ -113,8 +124,22 @@ };

/**
* Query children with specific `data-`attribute
* @func getChildrenWithData
* @static
* @param {HTMLNode} parentNode
* @param {string} dataKey – data-key. data-baz-key, baz-key and bazKey are equivalent
* @param {string} [dataValue]
* @param {string} dataKey – data-key. `data-baz-key`, `baz-key` and `bazKey` are equivalent
* @param {string} [dataValue] - value of a `data-`attribute
* @returns {NodeList}
* @example
* ```javascript
* // <div id="parent">
* // <div data-user-id="1">yep</div>
* // <div data-user-id="2">nope</div>
* // </div>
*
* Baz.h.getChildrenWithData(window.parent, 'data-user-id', 1)[0].textContent === 'yep'
* Baz.h.getChildrenWithData(window.parent, 'user-id', 1)[0].textContent === 'yep'
* Baz.h.getChildrenWithData(window.parent, 'userId', 2)[0].textContent === 'nope'
* ```
*/
var getChildrenWithData = function(parentNode, dataKey, dataValue) {
h.getChildrenWithData = function(parentNode, dataKey, dataValue) {
var prefixedDataKey = _prefixDataKey(dataKey);

@@ -132,5 +157,2 @@ var query;

module.exports = {
getAttrs: getAttrs,
getChildrenWithData: getChildrenWithData,
};
module.exports = h;
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