Skip to content

Commit

Permalink
Using separate vars (and fixing indentation) in widgets.js
Browse files Browse the repository at this point in the history
  • Loading branch information
ljharb committed Sep 25, 2014
1 parent 43d029b commit 440bdbf
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions lib/widgets.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@
var is = require('is');
var tag = require('./tag');

var dataRegExp = /^data-[a-z]+([-][a-z]+)*$/,
ariaRegExp = /^aria-[a-z]+$/,
legalAttrs = ['autocomplete', 'autocorrect', 'autofocus', 'autosuggest', 'checked', 'dirname', 'disabled', 'tabindex', 'list', 'max', 'maxlength', 'min', 'multiple', 'novalidate', 'pattern', 'placeholder', 'readonly', 'required', 'size', 'step'],
ignoreAttrs = ['id', 'name', 'class', 'classes', 'type', 'value'],
getUserAttrs = function (opt) {
return Object.keys(opt).reduce(function (attrs, k) {
if ((ignoreAttrs.indexOf(k) === -1 && legalAttrs.indexOf(k) > -1) || dataRegExp.test(k) || ariaRegExp.test(k)) {
attrs[k] = opt[k];
}
return attrs;
}, {});
};
var dataRegExp = /^data-[a-z]+([-][a-z]+)*$/;
var ariaRegExp = /^aria-[a-z]+$/;
var legalAttrs = ['autocomplete', 'autocorrect', 'autofocus', 'autosuggest', 'checked', 'dirname', 'disabled', 'tabindex', 'list', 'max', 'maxlength', 'min', 'multiple', 'novalidate', 'pattern', 'placeholder', 'readonly', 'required', 'size', 'step'];
var ignoreAttrs = ['id', 'name', 'class', 'classes', 'type', 'value'];
var getUserAttrs = function (opt) {
return Object.keys(opt).reduce(function (attrs, k) {
if ((ignoreAttrs.indexOf(k) === -1 && legalAttrs.indexOf(k) > -1) || dataRegExp.test(k) || ariaRegExp.test(k)) {
attrs[k] = opt[k];
}
return attrs;
}, {});
};

// used to generate different input elements varying only by type attribute
var input = function (type) {
Expand Down

0 comments on commit 440bdbf

Please sign in to comment.