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

formist

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

formist - npm Package Compare versions

Comparing version 0.1.5 to 0.1.6

14

lib/field.js

@@ -38,2 +38,4 @@

this.value = this.options.value || undefined;
for (var i = 0; i < this.options.options.length; i++) {

@@ -82,5 +84,13 @@

var tag = new Tag('option', this.options.options[i].attributes, this.options.options[i].label);
content = content + tag.render();
var optionTag,
attr = this.options.options[i].attributes;
// determine if this option is selected
if (this.value === (this.options.options[i].value || this.options.options[i].label)) {
attr.selected = true;
}
optionTag = new Tag('option', attr, this.options.options[i].label);
content = content + optionTag.render();
}

@@ -87,0 +97,0 @@

2

package.json
{
"name": "formist",
"version": "0.1.5",
"version": "0.1.6",
"description": "A library to publish, consume and validate HTML5 forms.",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -518,2 +518,45 @@

describe("with a selected option", function () {
it("as an array of strings", function () {
form.add(new formist.Field('select', {
options: ['Australia','UK','US'],
value: 'UK'
}));
expect(form.render()).to.equal('<form><div class="field"><select><option>Australia</option><option selected>UK</option><option>US</option></select></div></form>');
});
it("as an array of objects (label only)", function () {
form.add(new formist.Field('select', {
options: [{label:'Australia'},{label:'UK'},{label:'US'}],
value: 'US'
}));
expect(form.render()).to.equal('<form><div class="field"><select><option>Australia</option><option>UK</option><option selected>US</option></select></div></form>');
});
it("as an array of objects (label and value)", function () {
form.add(new formist.Field('select', {
options: [{label:'Australia',value:'a'},{label:'UK',value:'uk'},{label:'US',value:'us'}],
value: 'a'
}));
expect(form.render()).to.equal('<form><div class="field"><select><option value="a" selected>Australia</option><option value="uk">UK</option><option value="us">US</option></select></div></form>');
});
it("as an array of objects with a selected attribute", function () {
form.add(new formist.Field('select', {
options: [{label:'Australia',value:'a',attributes:{selected:true}},{label:'UK',value:'uk'},{label:'US',value:'us',attributes:{disabled:true}}]
}));
expect(form.render()).to.equal('<form><div class="field"><select><option selected value="a">Australia</option><option value="uk">UK</option><option disabled value="us">US</option></select></div></form>');
});
});
});

@@ -520,0 +563,0 @@

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