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

assert-element

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

assert-element - npm Package Compare versions

Comparing version 0.0.3 to 0.1.0

2

component.json
{
"name": "assert-element",
"version": "0.0.3",
"version": "0.1.0",
"dependencies": {

@@ -5,0 +5,0 @@ "component/assert": "*"

0.1.0 / 2015-09-11
==================
* hasAttribute: supporting function argument
0.0.3 / 2015-08-20

@@ -3,0 +8,0 @@ ==================

@@ -33,3 +33,9 @@

assert(attr in node.attributes, 'expected to find the attribute ' + attr + ' in the given node');
if (value) assert.strictEqual(node.attributes[attr], value);
if (value) {
if (typeof value === 'function') {
value(node.attributes[attr]);
} else {
assert.strictEqual(node.attributes[attr], value);
}
}
};

@@ -90,3 +96,2 @@

exports.hasChild = function (node, index, criteria) {
if (arguments.length === 2) criteria = noop;
exports.isNode(node);

@@ -96,8 +101,12 @@ assert(node.children.length > 0, 'provided node has no children');

assert(index >= 0, 'provided index cannot be negative');
var child = node.children[index];
assert(child !== undefined, 'child does not exist at the given index');
if (typeof criteria === 'function') {
criteria(child);
} else {
assert.deepEqual(child, criteria);
assert(typeof child !== 'undefined', 'child does not exist at the given index');
if (criteria) {
if (typeof criteria === 'function') {
criteria(child);
} else {
assert.deepEqual(child, criteria);
}
}

@@ -104,0 +113,0 @@ };

{
"name": "assert-element",
"version": "0.0.3",
"version": "0.1.0",
"description": "Assertions for checking virtual nodes used by Deku/React/etc",

@@ -5,0 +5,0 @@ "repository": "dekujs/assert-element",

@@ -28,2 +28,11 @@ # assert-element

When using a `Function`, it will be invoked with the attribute value. From there, you
can run any other assertion that should throw if the value is invalid.
```js
assert.hasAttribute(<Select options={[ 'a', 'b' ]} />, 'options', function (options) {
assert.deepEqual(options, [ 'a', 'b', 'c' ]); // will fail
});
```
**NOTE:** this allows for falsy values, as an attribute can be present but intentionally

@@ -30,0 +39,0 @@ false, such as `checked={false}`.

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