Socket
Socket
Sign inDemoInstall

ampersand-checkbox-view

Package Overview
Dependencies
27
Maintainers
9
Versions
13
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 6.0.0 to 6.1.0

4

ampersand-checkbox-view.js

@@ -29,2 +29,3 @@ /*$AMPERSAND_VERSION*/

this.required = (typeof opts.required === 'boolean') ? opts.required : false;
this.disabled = (typeof opts.disabled === 'boolean') ? opts.disabled : false;
this.validClass = opts.validClass || 'input-valid';

@@ -65,2 +66,3 @@ this.invalidClass = opts.invalidClass || 'input-invalid';

this.input.checked = !!this.value;
this.input.disabled = this.disabled;
this.input.name = this.name;

@@ -75,3 +77,3 @@ this.labelEl.textContent = this.label;

this.test();
if (this.parent) this.parent.update(this);
if (this.parent && this.parent.update) this.parent.update(this);
},

@@ -78,0 +80,0 @@ // set the error message if exists

{
"name": "ampersand-checkbox-view",
"description": "A view module for intelligently rendering and validating checkbox input. Works well with ampersand-form-view.",
"version": "6.0.0",
"version": "6.1.0",
"author": "Henrik Joreteg <henrik@andyet.net>",

@@ -15,3 +15,3 @@ "browserify": {

"dependencies": {
"ampersand-dom": "^1.4.0",
"ampersand-dom": "^1.5.0",
"ampersand-version": "^1.0.2",

@@ -21,8 +21,8 @@ "ampersand-view": "^10.0.1"

"devDependencies": {
"ampersand-view-conventions": ">=1.1.6",
"jshint": "~2.8.0",
"phantomjs-prebuilt": "^2.1.12",
"precommit-hook": "~3.0.0",
"tape": "^4.4.0",
"zuul": "^3.9.0"
"ampersand-view-conventions": "^1.1.8",
"jshint": "^2.9.4",
"phantomjs-prebuilt": "^2.1.14",
"precommit-hook": "^3.0.0",
"tape": "^4.6.3",
"zuul": "^3.11.1"
},

@@ -29,0 +29,0 @@ "homepage": "https://github.com/ampersandjs/ampersand-checkbox-view",

@@ -52,3 +52,5 @@ # ampersand-checkbox-view

// whether or not this field is required
required: true, // true by default
required: true, // false by default
// whether or not to disable this field
disabled: false, //false by default
// class to set on input when input is valid

@@ -55,0 +57,0 @@ validClass: 'input-valid', // <- that's the default

@@ -11,2 +11,3 @@ var test = require('tape');

var counter;
var view;
function getParent() {

@@ -21,7 +22,22 @@ counter = 0;

var view = new CheckboxView({name: 'checker', autoRender: true});
//default test
view = new CheckboxView({
name: 'checker',
autoRender: true
});
t.strictEqual(view.value, false ,'should start out as false');
t.equal(view.value, view.input.checked, 'value should be same as input value');
t.strictEqual(view.required, false, 'required should be false by default');
t.strictEqual(view.disabled, false, 'disabled should be false by default');
t.strictEqual(view.input.disabled, false, 'disabled should be false by default');
view = new CheckboxView({name: 'checker', label: 'checker', parent: getParent(), autoRender: true});
//test label content
view = new CheckboxView({
name: 'checker',
label: 'checker',
parent: getParent(),
autoRender: true
});
t.equal(view.labelEl.textContent, 'checker', 'should set label text');

@@ -34,5 +50,15 @@

view = new CheckboxView({name: 'checked', required: true, parent: getParent(), autoRender: true});
//test parent
view = new CheckboxView({
name: 'checked',
required: true,
parent: getParent(),
autoRender: true
});
t.strictEqual(view.el.children[2].style.display, 'none', 'should not show error right away');
t.equal(counter, 1, 'parent update should have been called once (setValue called on init)');
t.strictEqual(view.required, true, 'required should be true');
t.strictEqual(view.disabled, false, 'disabled should be false');
t.strictEqual(view.input.disabled, false, 'disabled should be false');

@@ -53,6 +79,17 @@ // check it directly

view = new CheckboxView({name: 'checked', required: true, parent: getParent(), value: true, autoRender: true});
//test reset
view = new CheckboxView({
name: 'checked',
required: true,
parent: getParent(),
value: true,
autoRender: true
});
view.setValue(false);
view.reset();
t.equal(view.value, true, 'resets to original value');
t.strictEqual(view.required, true, 'required should be true');
t.strictEqual(view.disabled, false, 'disabled should be false');
t.strictEqual(view.input.disabled, false, 'disabled should be false');

@@ -62,2 +99,21 @@ view.clear();

t.end();
//test disabled
view = new CheckboxView({
name: 'checked',
required: true,
disabled: true,
autoRender: true
});
t.strictEqual(view.disabled, true, 'disabled should be true');
t.strictEqual(view.input.disabled, true, 'disabled should be true');
//test throw when lacking name
t.throws(function() {
view = new CheckboxView({
required: true,
autoRender: true
});
}, 'should throw when there is no `name`');
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc