can-define
Advanced tools
Comparing version 2.2.1 to 2.2.2
@@ -28,3 +28,4 @@ "use strict"; | ||
var newSymbol = canSymbol.for("can.new"); | ||
var newSymbol = canSymbol.for("can.new"), | ||
serializeSymbol = canSymbol.for("can.serialize"); | ||
@@ -799,4 +800,13 @@ var eventsProto, define, | ||
} | ||
else if(isDefineType(value)) { | ||
definition = {type: value}; | ||
else if(value && (value[serializeSymbol] || value[newSymbol]) ) { | ||
definition = {}; | ||
var serialize = value[serializeSymbol]; | ||
if(serialize) { | ||
definition.serialize = function(val){ | ||
return serialize.call(val); | ||
}; | ||
} | ||
if(value[newSymbol]) { | ||
definition.type = value[newSymbol]; | ||
} | ||
} | ||
@@ -803,0 +813,0 @@ else if(typeof value === "function") { |
@@ -1279,3 +1279,3 @@ var QUnit = require("steal-qunit"); | ||
QUnit.test("use can.new for conversion", function(){ | ||
QUnit.test("use can.new and can.serialize for conversion", function(){ | ||
var Status = canReflect.assignSymbols({},{ | ||
@@ -1291,3 +1291,6 @@ "can.new": function(val){ | ||
}; | ||
} | ||
}, | ||
"can.serialize": function(){ | ||
return this.toUpperCase(); | ||
} | ||
}); | ||
@@ -1301,3 +1304,5 @@ | ||
var todo = new Todo({status: "NEW"}); | ||
QUnit.equal(todo.status, "new", "converted"); | ||
QUnit.equal(todo.status, "new", "converted during set"); | ||
QUnit.deepEqual(todo.serialize(),{status: "NEW"}, "serialized to upper case"); | ||
}); |
{ | ||
"name": "can-define", | ||
"version": "2.2.1", | ||
"version": "2.2.2", | ||
"description": "Create observable objects with JS dot operator compatibility", | ||
@@ -5,0 +5,0 @@ "main": "can-define.js", |
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
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
301927
7275