Skip to content

Commit

Permalink
added support for date strings in component attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
bsatrom committed May 3, 2013
1 parent 0709e34 commit 547826f
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 12 deletions.
11 changes: 9 additions & 2 deletions src/attrs.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
function takeAttributes() {
// for each attribute
forEach(this.attributes, function(a) {
// try to match this attribute to a property (attributess are
// try to match this attribute to a property (attributes are
// all lower-case, so this is case-insensitive search)
var name = propertyForAttribute.call(this, a.name);
if (name) {
Expand All @@ -71,7 +71,7 @@
}
// get original value
var defaultValue = this[name];
// deserialize Boolean or Number values from attribute
// deserialize Boolean, Date String or Number values from attribute
var value = deserializeValue(a.value, defaultValue);
// only act if the value has changed
if (value !== defaultValue) {
Expand Down Expand Up @@ -102,6 +102,13 @@
case 'false':
return inferredType == 'boolean' ? false : inValue;
}

// Check for date values (YYYY[./-]MM[./-]DD format)
if (inValue.match(/^\d{4}[./-]\d{2}[./-]\d{2}$/g)) {
return inValue;
}

// Check for float
var float = parseFloat(inValue);
return isNaN(float) ? inValue : float;
}
Expand Down
10 changes: 5 additions & 5 deletions toolkit.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion toolkit.min.js.map

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions toolkit.native.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion toolkit.native.min.js.map

Large diffs are not rendered by default.

0 comments on commit 547826f

Please sign in to comment.