can-map-define
Advanced tools
Comparing version 4.0.0 to 4.1.0
@@ -7,6 +7,7 @@ /* jshint asi: false */ | ||
var compute = require('can-compute'); | ||
var canReflect = require('can-reflect'); | ||
require('./can-map-define'); | ||
QUnit.module('can/map/define'); | ||
QUnit.module('can-map-define'); | ||
@@ -1509,1 +1510,49 @@ // remove, type, default | ||
}); | ||
QUnit.test("can.hasKey", function() { | ||
var Parent = CanMap.extend({ | ||
define: { | ||
parentProp: { | ||
type: "*" | ||
}, | ||
parentDerivedProp: { | ||
get: function() { | ||
if (this.parentProp) { | ||
return "parentDerived"; | ||
} | ||
} | ||
} | ||
} | ||
}); | ||
var VM = Parent.extend({ | ||
define: { | ||
prop: { | ||
type: "*" | ||
}, | ||
derivedProp: { | ||
get: function() { | ||
if (this.prop) { | ||
return "derived"; | ||
} | ||
} | ||
} | ||
} | ||
}); | ||
var vm = new VM(); | ||
// hasKey | ||
equal(canReflect.hasKey(vm, "prop"), true, "vm.hasKey('prop') true"); | ||
equal(canReflect.hasKey(vm, "derivedProp"), true, "vm.hasKey('derivedProp') true"); | ||
equal(canReflect.hasKey(vm, "parentProp"), true, "vm.hasKey('parentProp') true"); | ||
equal(canReflect.hasKey(vm, "parentDerivedProp"), true, "vm.hasKey('parentDerivedProp') true"); | ||
equal(canReflect.hasKey(vm, "anotherProp"), false, "vm.hasKey('anotherProp') false"); | ||
vm.attr('lateProp', 'something'); | ||
equal(canReflect.hasKey(vm, "lateProp"), true, "vm.hasKey('lateProp') true"); | ||
}); |
@@ -9,2 +9,3 @@ var dev = require('can-util/js/dev/dev'); | ||
var compute = require('can-compute'); | ||
var canReflect = require('can-reflect'); | ||
require('can-list'); | ||
@@ -71,3 +72,2 @@ | ||
var oldSetupDefaults = CanMap.prototype._setupDefaults; | ||
@@ -373,2 +373,10 @@ CanMap.prototype._setupDefaults = function(obj) { | ||
canReflect.assignSymbols(proto, { | ||
"can.hasKey": function(key) { | ||
var defined = this.define && key in this.define; | ||
var exists = this._data && key in this._data; | ||
return defined || exists; | ||
} | ||
}); | ||
module.exports = define; |
{ | ||
"name": "can-map-define", | ||
"version": "4.0.0", | ||
"version": "4.1.0", | ||
"description": "Define rich attribute behavior", | ||
@@ -43,2 +43,3 @@ "homepage": "https://canjs.com", | ||
"can-queues": "^1.0.1", | ||
"can-reflect": "^1.15.2", | ||
"can-util": "^3.9.0" | ||
@@ -45,0 +46,0 @@ }, |
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
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
80320
1649
0
7
+ Addedcan-reflect@^1.15.2