can-map-define
Advanced tools
Comparing version 3.0.0-pre.2 to 3.0.0-pre.3
@@ -1104,3 +1104,3 @@ /* jshint asi: false */ | ||
equal(t.attr("boolean"), false, "converted to boolean"); | ||
equal(t.attr("boolean"), undefined, "converted to boolean"); | ||
@@ -1126,3 +1126,3 @@ equal(t.attr("htmlbool"), false, "converted to htmlbool"); | ||
equal(t.attr("boolean"), false, "converted to boolean"); | ||
equal(t.attr("boolean"), null, "converted to boolean"); | ||
@@ -1237,1 +1237,64 @@ equal(t.attr("htmlbool"), false, "converted to htmlbool"); | ||
}); | ||
test("nullish values are not converted for Type", function(assert) { | ||
var VM = CanMap.extend({ | ||
define: { | ||
map: { | ||
Type: CanMap | ||
}, | ||
notype: {}, | ||
} | ||
}); | ||
var vm = new VM({ | ||
num: 1, | ||
bool: true, | ||
htmlbool: "foo", | ||
str: "foo", | ||
date: Date.now(), | ||
map: {}, | ||
notype: {} | ||
}); | ||
// Sanity check | ||
assert.ok(vm.attr("map") instanceof CanMap, "map is a Map"); | ||
assert.ok(vm.attr("notype") instanceof CanMap, "notype is a Map"); | ||
vm.attr({ | ||
map: null, | ||
notype: null | ||
}); | ||
assert.equal(vm.attr("map"), null, "map is null"); | ||
assert.equal(vm.attr("map"), null, "notype is null"); | ||
}); | ||
test("Wildcard serialize doesn't apply to getter properties (#4)", function() { | ||
var VM = CanMap.extend({ | ||
define: { | ||
explicitlySerialized: { | ||
get: function () { | ||
return true; | ||
}, | ||
serialize: true | ||
}, | ||
implicitlySerialized: { | ||
get: function () { | ||
return true; | ||
} | ||
}, | ||
'*': { | ||
serialize: true | ||
} | ||
} | ||
}); | ||
var vm = new VM(); | ||
vm.bind('change', function() {}); | ||
deepEqual(vm.serialize(), { | ||
explicitlySerialized: true, | ||
implicitlySerialized: true | ||
}); | ||
}); |
@@ -220,2 +220,5 @@ var dev = require('can-util/js/dev/dev'); | ||
'boolean': function(val) { | ||
if(val == null) { | ||
return val; | ||
} | ||
if (val === 'false' || val === '0' || !val) { | ||
@@ -275,4 +278,4 @@ return false; | ||
} | ||
// If there's a Type create a new instance of it | ||
if (Type && !(newValue instanceof Type)) { | ||
// If there's a Type and newValue is non-null create a new instance of it | ||
if (Type && newValue != null && !(newValue instanceof Type)) { | ||
newValue = new Type(newValue); | ||
@@ -356,3 +359,4 @@ } | ||
// check there is a serializer so we aren't doing extra work on serializer:false | ||
serializer = this.define && this.define[attr] && this.define[attr].serialize; | ||
// also check for a wildcard serializer | ||
serializer = this.define && (this.define[attr] && this.define[attr].serialize || this.define['*'] && this.define['*'].serialize); | ||
if (serializer) { | ||
@@ -359,0 +363,0 @@ val = serializeProp(this, attr, this.attr(attr)); |
{ | ||
"name": "can-map-define", | ||
"version": "3.0.0-pre.2", | ||
"version": "3.0.0-pre.3", | ||
"description": "Define rich attribute behavior", | ||
@@ -27,3 +27,3 @@ "homepage": "https://canjs.com", | ||
"build": "node build.js", | ||
"document": "documentjs", | ||
"document": "bit-docs", | ||
"develop": "done-serve --static --develop --port 8080" | ||
@@ -67,3 +67,9 @@ }, | ||
"devDependencies": { | ||
"bit-docs": "0.0.7", | ||
"can-component": "^3.0.0-pre.11", | ||
"can-fixture": "^0.3.0", | ||
"can-list": "^3.0.0-pre.1", | ||
"can-model": "^2.3.11", | ||
"can-route": "^3.0.0-pre.8", | ||
"can-stache": "^3.0.0-pre.11", | ||
"cssify": "^0.6.0", | ||
@@ -79,3 +85,23 @@ "documentjs": "^0.4.2", | ||
"testee": "^0.2.4" | ||
}, | ||
"bit-docs": { | ||
"dependencies": { | ||
"bit-docs-glob-finder": "^0.0.5", | ||
"bit-docs-dev": "^0.0.3", | ||
"bit-docs-js": "^0.0.3", | ||
"bit-docs-generate-readme": "^0.0.8" | ||
}, | ||
"glob": { | ||
"pattern": "**/*.{js,md}", | ||
"ignore": [ | ||
"**/node_modules/*", | ||
"node_modules/**/*", | ||
"**/*{-,_,}{test,qunit}{s,}.js" | ||
] | ||
}, | ||
"readme": { | ||
"apis": "./doc/apis.json" | ||
}, | ||
"parent": "can-map-define" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
76355
25
1431
17
1